Indent in
1 indents = 4 spaces
used in The hierarchical relationship of the code is indicated in Python
Indentation is The only means of demonstrating the program framework in the Python language
Comments
N Note: The programmer adds the description information to the code that is not executed by the computer
N Two ways to annotate:
N Single-line comments start with #
multiple lines of comments to "' Start and end
Constants and variables
N Constants: Elements in a program where values do not change
n Benefits of using constants: For example, a program contains a constant, pi=3.14 if you use PI multiple times in a program, modify the constant definition directly when we need more precise values, without having to modify the values for each use
n variables: Elements in a program where values change or can change
N in the Python language, there is basically no difference in the use of variables and constants
Named
N naming: Associating an identifier with a program element to ensure uniqueness
n variables and constants require a name
N Naming rules:
n a combination of uppercase and lowercase letters, numbers, and underscores, but the first letter can be either uppercase or lowercase or underlined , and cannot use spaces.
n non-alphabetic symbols such as Chinese can also be used as names.
n the following are the legitimately named identifiers:
Python_is_good Python_is_not_good
_is_it_a_question_ python language
(Chinese characters can also be variable names)
Constants, variables, and names
n identifiers are case sensitive and cannot be the same as reserved words
Npython 3.x reserved word list (33)
Python syntax element analysis