Python Variables
In Python variables are created the moment you assign a value to it:
Example
Variables in Python:
x = 5
y = "Hello, World!"
Python has no command for declaring a variable.
a, b = 0, 1
a multiple assignments: the variables 'a' and '
b'
simultaneously get the new values 0 and 1.
a, b = b, a+b
demonstrates that the expressions on the right-hand side are all evaluated first before any of the assignments take place. The right-hand side expressions are evaluated from the left to the right
implies it would become something like this in first parse
a, b = b, 1
implies it would become something like this in first parse
a, b = 1, 1
implies 'a' would get 1 and 'b' would the evaluation of a+b i.e. 0+1 = 1
------------Also Python supports
a=b=c=d = 17
implies all above variables have been assigned same value of 17
------------Different data types -------
intNum,nameString = 20,"Ramit Girdhar"
Comments
Post a Comment