- Python 数字类型
- 1. Booleans
- 1.1 常见搭配表达符
- 2. Integers(int)
- 2.1 常见操作符
- 3. Floating point
- 3.1 常见操作符
- 4. math 模块
- 5. 比较符
- 6. 类型转换
Python 有4种数组类型:
- Booleans (布尔)
- Integers (整数)
- Floating point (浮点数)
- Complex (Imaginary numbers) (复数和虚数)
a = True b = False1.1 常见搭配表达符
and, or, not2. Integers(int)
a = 37 b = -299392993727716627377128481812241231 c = 0x7fa8 # Hexadecimal d = 0o253 # Octal e = 0b10001111 # Binary2.1 常见操作符
x + y Add x - y Subtract x * y Multiply x / y Divide (produces a float) x // y Floor Divide (produces an integer) x % y Modulo (remainder) x ** y Power x << n Bit shift left x >> n Bit shift right x & y Bit-wise AND x | y Bit-wise OR x ^ y Bit-wise XOR ~x Bit-wise NOT abs(x) Absolute value3. Floating point
a = 37.45 b = 4e5 # 4 x 10**5 or 400,000 c = -1.345e-103.1 常见操作符
与整数的操作符相比,没有了按位运算。
x + y Add x - y Subtract x * y Multiply x / y Divide x // y Floor Divide x % y Modulo x ** y Power abs(x) Absolute Value4. math 模块
import math a = math.sqrt(x) b = math.sin(x) c = math.cos(x) d = math.tan(x) e = math.log(x)5. 比较符
x < y Less than x <= y Less than or equal x > y Greater than x >= y Greater than or equal x == y Equal to x != y Not equal to6. 类型转换
a = int(x) Convert x to integer b = float(x) Convert x to float



