Python Variables:
Variable is a name of a memory loacation to store a value.
Declaration
When you assign a value to variable_name then automatically the memory is assigned for the variable.
Example
- var1=200 # int declaration
- var2=200.3 # floating point declaration
- var3="scanftree" # string declaration
- print var1
- print var2
- print var3
Output
200 200.3 scanftree
Multiple Assignment:
Python allows you to assign a single value to several variables simultaneously.
Example:
- a = b = c = 10 # approach 1
- or
- a, b, c =10, 20, "scanftree.com" # approach 2
In the first approach all variables a, b, c are assigned value 10
In the second approach a, b are assigned values 10 and 20 whereas c has been assigned with scanftree.com
- var1=100
- var2=30.3
- var3="scanftree"
- print var1
- print var2
- print var3
In the next chapter you are going to learn data-types of python