Arithmetic Operations

beginner20 min

Learning objectives

  • Apply arithmetic operators correctly
  • Distinguish between floating-point and integer division
  • Explain modulus, exponentiation, rounding and truncation
  • Develop algorithms that perform mathematical calculations

Learn

AQA 4.1.1.3 — Arithmetic operations

Retrieval: you've already used variables and constants to store numeric values (the previous lesson's price, total) - this lesson is about the operators you use to actually combine and transform those values.

OperationPythonExampleResult
Addition+5 + 27
Subtraction-5 - 23
Multiplication*5 * 210
Floating-point division/5 / 22.5
Integer (floor) division//5 // 22
Modulus (remainder)%5 % 21
Exponentiation**5 ** 225

Integer division vs floating-point division

This is the operator students most often mix up. / always gives a float, even when the numbers divide evenly (10 / 2 is 5.0, not 5). // discards the remainder entirely: 7 // 2 is 3, not 3.5.

Modulus — more useful than it looks

% gives you the remainder, which is exactly what you need to check divisibility:

if number % 2 == 0:
    print("Even")
else:
    print("Odd")

Rounding vs truncation

round(3.7) gives 4 (rounds to the nearest whole number). int(3.7) gives 3 (truncates — simply discards everything after the decimal point, it does not round). These behave differently for negative numbers too: int(-3.7) is -3, not -4.

Worked example — a simple calculator

a = float(input("First number: "))
b = float(input("Second number: "))
print(f"Sum: {a + b}")
print(f"Difference: {a - b}")
print(f"Product: {a * b}")
print(f"Quotient: {a / b}")

Challenge

Extend the calculator to also print a // b, a % b and a ** b, and explain in a sentence what each one calculates.

Practise

Apply what you've just learned in the Coding Lab.

Open Coding Lab

Test yourself

Check your understanding with exam-style questions.

Go to Exam Practice
Log in to track this lesson on your progress dashboard.
Log in