Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Arithmetic operators

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

45 minutes

Sharing a pizza bill

Four friends share a 50 pound pizza bill. How much does each person pay? 50 divided by 4 is 12.5.

But they only have pound coins. Each friend puts in 12, and 2 pounds are left over to pay. A program must know how to say both things.

Key words

WordWhat it meansExample
OperatorA symbol that does something to values.+
Arithmetic operatorAn operator for maths.+ - * /
ExponentiationMultiplying a number by itself again and again. It is also called power.2 ** 3 is 2 x 2 x 2, which is 8
Integer divisionDivision that gives only the whole number part.7 // 2 is 3
ModulusThe remainder after a division.7 % 2 is 1
RemainderWhat is left over after sharing equally.7 shared by 2 leaves 1
FloatA number with a decimal point.12.5
IntegerA whole number.12

The cells students fill in are left blank in this preview.

Try it: the first four

Code: python
print(8 + 2)
print(8 - 2)
print(8 * 2)
print(8 / 2)

# Change the numbers and run again.
# Notice that 8 / 2 gives 4.0, a float.

The seven arithmetic operators

OperatorNameExampleResult
`+`Add`7 + 2`9
`-`Subtract`7 - 2`5
`*`Multiply`7 * 2`14
`/`Divide`7 / 2`3.5
`**`Exponentiation (power)`2 ** 3`8
`//`Integer division`7 // 2`3
`%`Modulus (remainder)`7 % 2`1

The cells students fill in are left blank in this preview.

Work it out

Have a go

Work it out

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Worked example: 50 shared by 4

QuestionOperatorCalculationAnswer
How much each, with a decimal?`/`50 / 412.5
How many whole pounds each?`//`50 // 412
How many pounds are left over?`%`50 % 42
Check: 4 people times 12, plus the leftover`*` and `+`4 * 12 + 250

The cells students fill in are left blank in this preview.

Integer division and modulus

Think about sharing sweets (small candies). 7 sweets, 2 friends. Each friend gets 3. One sweet is left.

7 // 2 gives 3: how many times 2 fits into 7. 7 % 2 gives 1: what is left. You can use them together to change minutes into hours and minutes.

Try it: minutes to hours

Code: python
total = 135

hours = total // 60
minutes = total % 60

print(hours, "hours", minutes, "minutes")

# 60 goes into 135 two times, so hours is 2.
# 135 - 120 leaves 15, so minutes is 15.
# Change total to 200.

More than one operator

You can use several operators in one line. Python works out what is inside brackets first.

So (2 + 3) * 4 is 20. The full order of operations has its own lesson.

The lesson goes on

7 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.