The Six Core Operators
+addition-subtraction*multiplication/true division (always returns float)//floor division (drops the remainder)%modulo (the remainder)**exponent
7 / 2 # 3.5 7 // 2 # 3 7 % 2 # 1 2 ** 10 # 1024
Operator Precedence
Python follows standard math order: parentheses, exponents, multiply/divide, add/subtract. Use brackets when in doubt.
result = 2 + 3 * 4 # 14 result = (2 + 3) * 4 # 20
Combined Assignment
x = 10 x += 5 # 15 x *= 2 # 30 x //= 4 # 7
HKDSE Modulo Pattern
if n % 2 == 0:
print("even")
else:
print("odd")
Practise this on PyForm — free
PyForm runs Python in your browser with an AI tutor trained for HKDSE. No install, no credit card.
Open PyForm →