- Three characteristic variables
type:
viewing data type
id:
represents the variable address in memory, is a string of numbers
value:
the value of variables
- Notes
Description of the code is doing
Single-line comments:
# Single line comment content
Multiline comments:
'' '
multi-line comment content
' ''
- The user interacts with the program
input
- formatted output
% S: placeholder
- basic operators
- Arithmetic Operators
- Comparison Operators
- logical operators
- assignment operators
- chain assignment
X = Y = 10
- Cross assignment
X, Y = Y, X
- decompression assignment
X = (l, 2,3)
X, Y, Z = ()
[l, 2,3]
- Process Control
对流程的控制,控制某些事件的发生
-if分支判断:
语法:
if 判断条件:
# 条件若成立执行
print('条件成立')
# 若if条件不成立,则执行此处
elif 判断条件:
print('另一个条件成立')
# 若if与elif条件不成立,则执行此处
else:
# 若条件不成立则执行
print('条件不成立!')