Python »

My Coding > Programming language > Python

Python

Python is a general-purpose programming language, so it can be used for many things. Python is used for web development, AI, machine learning, operating systems, mobile application development, and video games

Basic syntax

Comments

Comments can be started from # or kept in /* */ brackets or ''' multiline comment'''


# The full line is comment
print x # Comment at the end of the line
/* Comment inside line */ print x
'''
this is 
multiline
comment
'''

Defining variables in Python


# Define simple variable
a="long text"

# Define few variables with the same value
t=p=q=1024 #t=1024 p=1024 q=1024
print('The value of t is:',t)

# Define few variables with individual values
j,u,p="big",1344,512.57 # j='big' u=1344 p= 512.57
print('The value of j is:',j)

# Declare boolean variables
x,y = 10,5
z = x>y # z=false

# Check variable type with function type()
a=12
print('The data type of variable a is:', type(a))

# Convert variable type with int() float() chr() str()
a = chr(100) # a will set to 'd'


Published: 2021-09-04 11:09:46
Updated: 2021-09-11 03:34:31

Last 10 artitles


9 popular artitles

© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit.