V. Variables and Assignments
A variable in Python does not need to specify its type when declaring it, and it automatically determines the value based on your assignment.
For the assignment of a value type such as a number and a character, the variable is simply a reference to it and cannot be deleted directly (in fact, because of the garbage collection mechanism in Python, you can't really delete anything, and Python automatically judges it "no one" to delete it)
>>> a = 1>>> B = aprint(A, b)print(A, b)9 1
Vi. numbers
int: Signed integer (if out of range is automatically converted to a long integer)
A long integer (whose range depends on the user's virtual memory)
float: floating point
Complex: Complex numbers (imaginary numbers are denoted by the letter J at the end of the number)
BOOL: Boolean value (1 for true,0 represents false,true+false result of 1)
Seven, string
Strings can be defined using a pair of single quotes, double quotes, or three quotation marks;
The string is a sequence of characters, you can use the slice operation of the list to get the substring of the string, or you can use the subscript index to get the position of the characters, the first character subscript is 0, the last character subscript is (-1);
You can use the "+" sign to concatenate two strings (it will re-open a space in memory, create a new string to represent the result of the connection), you can use "*" to specify the number of repetitions of the string.
>>> py ='Python'>>> py[-1],py[0] ('N','P')>>> Py[1:-2], py[:], py[2:], Py[:3]('Yth','Python','Thon','Pyt')>>> he ='Hello'>>> he+py'Hellopython'>>> py*3'Pythonpythonpython'
Beginner Python (ii)