Python: doing maths with operators
Computers are brilliant calculators. Python has operators for adding and multiplying, and some special ones for whole-number division and remainders.
Arithmetic operators
| Operator | Meaning | Example | Result |
|---|---|---|---|
| + | add | 7 + 3 | 10 |
| - | subtract | 7 - 3 | 4 |
| * | multiply | 7 * 3 | 21 |
| / | divide | 7 / 2 | 3.5 |
| // | whole-number division (quotient) | 17 // 5 | 3 |
| % | remainder (modulus) | 17 % 5 | 2 |
| ** | power | 2 ** 3 | 8 |
Order of operations
print(2 + 3 * 4)
print((2 + 3) * 4)
Output:
14
20
In the first line 3 * 4 is done first. Brackets change the order.
Why // and % are useful
people = 4
print(sweets // people)
print(sweets % people)
Output:
5
3
23 sweets shared between 4 people: each gets 5, with 3 left over.
% is also handy for testing whether a number is even: n % 2 is 0 for even numbers.
Note: / always gives a decimal answer in Python, so 8 / 2 gives 4.0.
What does this print?
minutes = 135
print(minutes // 60)
print(minutes % 60)
- 135 // 60: 60 goes into 135 twice, so 2.
- 135 % 60: the remainder is 135 - 120 = 15.
- So 135 minutes is 2 hours 15 minutes.
Answer: 2 then 15
Python uses + - * / for basic maths, // for whole-number division, % for the remainder and ** for powers. Brackets are worked out first, then powers, then * and /, then + and -.
- AND
- A Boolean operator that gives True (1) only when both inputs are True.
- Output
- Information sent out from a computer, for example to a screen, speaker or printer.
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
What does this print?
print(23 // 5)Show the answer
Answer: 4
23 รท 5 = 4 remainder 3. // keeps the whole number: 4.
What does this print?
print(23 % 5)Show the answer
Answer: 3
23 รท 5 = 4 remainder 3. % gives the remainder: 3.
Check you have got it
Answer 7 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.