Variables in Python do not need to be declared, but each variable must be assigned a value before it is used, and the variable will not be created until the variable is assigned.
In Python, a variable is a variable, it has no type, what we mean by "type" is the type of the object in memory that the variable refers to.
The equal sign (=) is used to assign values to variables.
The left side of the equals (=) operator is a variable name, and the right side of the equals (=) operator is the value stored in the variable.
counter = 100 # integer variable miles = 1000.0 # float variable name = " runoob " # string
multiple variable assignments
Python allows you to assign values to multiple variables at the same time.
a = b = c = 1 The above example creates an integer object with a value of 1, and the three variables are allocated to the same memory space. or a, b, c = 1, 2, "liubao" In the above example, the two integer objects 1 and 2 are assigned to variables a and b, and the string object " runoob " is assigned to variable c.
Standard data types
There are six standard data types in Python 3:
- Number
- String (string)
- List
- Tuple (tuple)
- Sets
- Dictionary (dictionary)
Among the six standard data types of Python3:
- Immutable data (four): Number (number), String (string), Tuple (tuple), Sets (collection);
- Variable data (two): List (list), Dictionary (dictionary).
We mainly learn these six data types of python, which will be introduced in detail later