Skip to content
Menu

Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 2

Arithmetic operators and casting

Python's arithmetic operators including integer division (//), modulus (%) and exponent (**), the order of operations, and casting between strings, integers and floats with int(), float() and str().

Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

Whiteboard video lesson: Arithmetic operators and casting

8-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Use the arithmetic operators
  • Use // and % correctly
  • Apply the order of operations
  • Cast between data types

The method

  1. + − * / for add, subtract, multiply, divide.
  2. // integer division; % remainder; ** power.
  3. Brackets first, then **, then * / // %, then + −.
  4. int(), float(), str() change data type.

Key words: operator, integer division, modulus, casting, exponent.

Worked examples

Worked examples from the lesson, with every step.

Question 1

Evaluate 23 // 4 and 23 % 4.

  1. Step 1: 4 goes into 23 five times (20).
  2. Step 2: 23 − 20 = 3

Answer: 5 and 3

Question 2

What does this output? c:x = 10 c:y = 4 c:print(x / y, x // y, x % y)

  1. Step 1: 10 / 4 = 2.5
  2. Step 2: 10 // 4 = 2; 10 % 4 = 2

Answer: 2.5 2 2

Question 3

Evaluate 3 + 2 ** 2 * 5.

  1. Step 1: 2 ** 2 = 4
  2. Step 2: 4 × 5 = 20; 3 + 20 = 23

Answer: 23