Overview
Python arithmetic operators (+, -, *, /, //, %, **) perform basic maths on numbers.
Analogy
A calculator with extra buttons: // for floor divide, % for remainder, ** for power.
Step-by-step
- 5 + 3 = 8 (addition).
- 17 // 5 = 3 (floor division, discards remainder).
- 17 % 5 = 2 (remainder / modulo).
- 2 ** 10 = 1024 (exponentiation).
Visual
17 ÷ 5 = 3 remainder 2 → 17//5 == 3, 17%5 == 2
Common mistakes
- Using / when integer division is intended (5/2 is 2.5, not 2).
- Operator precedence surprises: 2+3*4 is 14, not 20.
Practice questions
- Compute the last digit of 12345 using %.
- Implement a simple interest formula.