Personal notes, only as a study record, if there is a mistake.
Variable naming rules:
1: Variable name must be a combination of English letters, underscores, numbers
2: Variable name cannot start with a number
3: Variable name cannot be a keyword in python
4: Variable name cannot be Chinese
The variable name in 5:python is suggested to be underlined if there are multiple words (other languages commonly used hump method)
Constants cannot be defined in 6:python: All variables in Python are mutable, so the constant is represented by the variable name in all Capitals
Variable assignment:
name1 = "Laowang"
Name2 = name1
name1 = "Xiaozhang"
Does the value of the name2 at this time also change?
A, no, the value of name2 is still "Laowang", the value of name1 becomes "Xiaozhang"
Deletion of variables:
Age = 20
del age(delete variable reference, not free memory, memory recycle processed by GC)
Python code:
python2.x: Default encoding ASCII
python3.x: Default encoded Unicode
Comments in Python:
Python single line comment: Pound sign "#"
Python Multiline Comment: Three quotation marks beginning and ending "" "" "" "" ""
In fact, the three quotation marks of a multiline comment in Python are not real comments, but rather unreferenced strings!
Because it is not referenced, a string of three quotation marks is ignored by the Python interpreter, so it can be used as a notation
Input ():
Name = input ("Please enter your name:")
age = Int (input ("Please enter your Ages:"))
Input received by default is the str type (string)
If...else. Statement:
If name = = "Laowang":
Print ("Lao Wang")
Else
Print ("Xiaoming")
Note:There is no else in Python, but it is elif shorthand.
The indentation of Python:
The TAB key and the space can not be mixed, either with the tab indent or with a space indent (any space, as long as the indentation consistent line), the official recommended indentation is four spaces (the Text Editor tab key into 4 spaces)
Python_01_ variable _ comment _input_if_ indent