Assign values to a variable: for example, A=1. When assigning a value to a variable, the variable is created to store the value in memory, which means that the variable is created in the memory space (corresponding to one address: one value)
Python is a dynamic type of language that can bind different types of values in the execution of a variable assignment, depending on the assigned value, which is the object's data type. It can be said that in Python the object has a data type variable with no data type.
The process of assigning a variable value:
>>> A = 1
1. Open a position in memory to represent the 1 object.
2. Create a variable A, if he has not been assigned a value before, a and object 1 link, if he was created and assigned before he will disconnect the previous object and break the existing link and create a new link with 1. (After running a=1, variable A becomes a reference of 1)
Variable Naming conventions:
Syntax: (underscore or letter) + (any number of letters, numbers, or underscores)
The variable name must begin with an underscore or letter, followed by any number of letters, numbers, or underscores.
Case-sensitive: Dream and Dream are different
Prohibit use of reserved words
Python allows you to assign values to multiple variables at the same time. For example:
A = b = c = 1
The above example creates an integer object with a value of 1 and three variables allocated to the same memory space.
You can also specify multiple variables for multiple objects. For example:
A, b, C = 1, 2, "John"
For the above example, two integer objects 1 and 2 are assigned to variables A and B, and the string object "John" is assigned to variable C.
Python variable (VARIAB)