Python Variables are nothing but the reserved memory locations to store the values. In other words, it is the name of the memory location where the data is stored. And if once the variable is stored a separate space is allocated in the memory. Moreover, we can define the variable name using the combination of letters, number, and underscore.
Click the here to know the programming structure of python
Assigning values to the variables :
In fact, there is no explicit declaration to store the memory. And we can easily define a variable using the ‘=’operator.
Example :
a = 20
b = 30
print a
Output:
20
Beside python online training suggest another type of declaring the variables.
Example :
a,b,c = 2,10,python
Note :
Python interpreter automatically identifies the types of variables
Can we re-declare a variable?
Today many starters have this question? Hope you got the answer after reading this. And the answer to the question is yes, we can re declare a variable. But the Variable stores the most recent value.
Ex :
x = ‘10’
Print(‘x’)
X=’abc’
Print(‘x’)
Output :
10
abc
Constants:
These are fixed values that cannot be altered.
Ex : pi= 22.7
Gravity =9.8
Place these values separate files like constant.py
Now we can execute this by the following command
Import constant
Print(constant.pi)
Print(constant.gravity)
So after running this command, we would get the following output
Output :
22.7
9.8
Willing to get certified on it Courses? Visit OnlineITGuru for Online Certification Courses
So till we seen the variable types, declarations. Now, its time to discuss tokens