Home > Article > Backend Development > Python learning basics - a detailed introduction to variables and assignments
Variables: The program will use a lot of temporary storage data when it is running. At this time, variables and the names of temporary data are used.
#Variables in Python do not need to be declared and can be used directly. The data type of the variable is determined by assignment.
>>> name="like" >>> name 'like' >>> age = 35 >>> name,age ('like', 35)
Use the type command to view the type of the variable:
>>> type(name) <class 'str'> >>> type(age) <class 'int'> >>> print(name,age) like 19
The variable stores not the assigned data, but the address where the data is located ( The address is not the address of the memory), the id can check the address of the variable
>>> a = 3 >>> b = a >>> id(a),id(b) (1661927952, 1661927952) >>> a = 5 >>> id(a),id(b) (1661928016, 1661927952)
Variable naming rules
1. Explicit, easy to understand .
2. Variable name can only be a combination of letters, underscores, and numbers. Numbers cannot begin, and cannot contain -!@#$%^&*() and other special symbols.
For example: nums_of_alex_gf = 19
NumsOfAlexGf = 19
The above is the detailed content of Python learning basics - a detailed introduction to variables and assignments. For more information, please follow other related articles on the PHP Chinese website!