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.

Practise this lesson free (7 questions)

Arithmetic operators

Python uses * for multiply and / for divide, not ร— and รท.
OperatorMeaningExampleResult
+add7 + 310
-subtract7 - 34
*multiply7 * 321
/divide7 / 23.5
//whole-number division (quotient)17 // 53
%remainder (modulus)17 % 52
**power2 ** 38

Order of operations

Python follows the same order as maths: brackets first, then powers, then multiply and divide, then add and subtract.
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

sweets = 23
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.
Worked example

What does this print?
minutes = 135
print(minutes // 60)
print(minutes % 60)

  1. 135 // 60: 60 goes into 135 twice, so 2.
  2. 135 % 60: the remainder is 135 - 120 = 15.
  3. So 135 minutes is 2 hours 15 minutes.

Answer: 2 then 15

Key idea

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 -.

Key words
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.

All KS3 Computing key terms and definitions โ†’

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. What does this print?
    print(23 // 5)

    Show the answer

    Answer: 4

    23 รท 5 = 4 remainder 3. // keeps the whole number: 4.

  2. 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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.