-
Types of numbers in python
- integer
- whole numbers
- takes up less space than floats
- floating point (floats)
- has decimals
- takes up more space than integers
- (any expression) + float = float
1 + 1.0 = 2.0
- complex
- long
- integer
-
Operators
# === Math ===
2 + 1
2 - 1
2 * 1
2 ** 3
4 % 2 # Modulo (remainder operation)
4 / 2 # division
4 // 2 # integer division
# === division ===
# division always returns a float
1 / 2 # 0.5
1 // 2 # 0 (rounds down)
10 / 3 # 3.3333...
10 // 3 # 3
# === Precedence ===
# 1) ** 2) *,/,//,% 3) +,- 4) ==,!=,<=,>=,<,>
# 5) not 6) and 7) or