Whenever we are writing any values in python language, Python store it in its memory area for program execution. If we want to use those values further continuously we have two methods i.e.
1. Access the address of the memory area in which python has stored it and then retrieve it as per requirement.
2. To provide a label or name to that memory area i.e. called as variable name
Variable names are nothing that is only memory locations that are reserved for storing values. If we want to access those values we can directly able to retrieve it by variable names. In other words, we can say that when we create any variable, some space is reserved in the memory. In a python program, variable gives data to the computer for processing.
There are some specific rules in python language for a variable that is given below:
* A variable name can begin with uppercase, lowercase or an underscore.
* Variable names are case sensitive.
* The number can be used at any position after starting position
* Keywords are not allowed
* Variable can never begin with numbers or special character
* No spaces are permitted in words and must be a single word
Assigning values to variables
There is no requirement of explicit declaration for the python variables for memory space reservation. It automatically happens while assigning values to the variable. For assigning any values to variables there is a usage of the equal sign (=).
Variable can be used for simplicity. For example, we have large integer's i.e. 476686979808098, instead of writing over and over again the same large value in a program, we can easily remember this large value by providing a label to that values i.e. val_int.
In which, val_int = 476686979808098 is an assignment statement that consists of variable name, assignment operator and value can be used for the variable.
al_int = 476686979808098
Algebra example in python
Variable can be reassigned to string
y = 89
y = "codingtag"
You can easily assign one single value to multiple variables at the same time with the use of multiple assignments.
p = q = r = 9
Several values to several variables within the same line are also permitted in python language
x, y, z = "codingtag", 31.6, 34