Like every programming language, Python also have keywords(Reserved Words). you can not use them as a variable name or any other identifier name.
Python Keywords List
Python Keywords are used to perform an internal operation. All the keywords of Python contain lower-case letters only.
Python Variables
A variable is a named memory allocation which may vary at the time of execution.
Exa: x=100
Here x is an int type of variable and the value 100 is assigning to x.
Unlike other programming languages, there is no required to specify any data type explicitly to declare a variable.
Example:
y=12.34
z=”Mama”
print(y)
print(z)
Output:
12.34
Mama
x1 = 100 # x1 is of type int
x1 = "Silan" # x1 is now of type str
print(x)
Here String variables can be declared either by using single or double or triple quotes. For ex;
x2 = "Silan"
# is the same as
x2 = 'Silan'
Variable Names
Examples:
mydata = "Silan"
my_data = "Silan"
_my_data = "Silan"
myData = "Silan"
MYDATA = "Silan"
mydata1 = "Silan"
1mydata = "Silan"
my-data = "Silan"
my data = "Silan"
#Variable manipulation
t1=100
t2=12.34
s1="Silan"
s2="Tutorial"
print(t1)
print(t2)
print(s1)
print(s2)
Output:
100
12.34
Silan
Tutorial
t1+t2
Output: 112.34
s1+s2
Output: 'SilanTutorial'
t1+s1
Output: TypeError: unsupported operand type(s) for +: 'int' and 'str'
Recommended Posts:
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc