变量
不同于其他的编程语言,使用Python变量前必须为其赋值,因为Python变量没有默认值。
在Python中,标识符只能由三部分构成:
- 字母
- 数字
- 下划线
且不能以数字开头。
Example:
- abcd_1 ✔
- 1_abcd ❌
语句
表达式和语句的界限并不清楚。
个人觉得这种概念上的东西不重要。
表达式在一定程度上往往涉及到赋值。
获取用户输入
input函数
>>> input("put in a number:")
put in a number:42
'42'
>>> x = input("x: ")
x: 32
>>> y = input("y: ")
y: 41
>>> print(int(x)*int(y))
1312