GCSE · Computer Science · Edexcel · Spec 1CP2

Programming arithmetic operators

Ask Python to share 14 counters between 3 people and it can give you three different answers. All three are right. The trick is knowing which one you asked for.

Computer Science · Python

14 counters, 3 people, three answers

Same 14, same 3, every line. Only the operator changes. Step through and watch each variable fill up.

Before you step: which line tells you how many counters each person gets, and which tells you how many are left on the table?

1 number = 14 / 3
2 counters_each = 14 // 3
3 counters_remaining = 14 % 3
numbercounters_eachcounters_remaining
4.666…

Output

 

Step 1: One slash: real division. The entire value gets divided, so there's no remainder at all — just a decimal, 4.666…. Great for maths. Useless if you're handing out actual counters.

1 / 3

Look at the symbol, not the numbers. The numbers never change.

Step 1 of 3: One slash: real division. The entire value gets divided, so there's no remainder at all — just a decimal, 4.666…. Great for maths. Useless if you're handing out actual counters..

Watch out: The trap: thinking 'divide' only means one thing. In Python, /, // and % all divide 14 by 3 — and hand back three different values.

Computer Science · Python

Which operation is it?

Sort each expression by the operation its operator performs.

Still to sort

Addition (0)

+

Subtraction (0)

-

Multiplication (0)

A single star: *

Where the line is: One star multiplies. Two stars (**) is a different operator.

Exponentiation (0)

Two stars: **

Where the line is: score ** 2 is score to the power of two. It is not score * 2.

Real division (0)

A single slash: /

Where the line is: The entire value is divided, so there is no remainder and the result can be a decimal.

Integer division (0)

A double slash: //

Where the line is: Any remainder is discarded, leaving only a whole number. Not the same as /.

Modulo (0)

The percent sign: %

Where the line is: Returns only the remainder of a division — nothing to do with percentages.

7 of 7 still to sort.

Pick an expression, then pick the operation its symbol performs. Two pairs of lookalikes are hiding in here.

Watch out: One star multiplies; two stars is exponentiation. One slash divides the entire value; two slashes throw the remainder away. One extra character, a completely different answer.

Computer Science · Order of operations

What does Python do first?

In number = 10 - 2 + 2 * 5, put the three steps in the order Python works them out

1 · Python does this first3 · Python does this last
  1. 10 - 2

  2. 8 + 10

  3. 2 * 5

Watch out: Left to right is only the rule for + and - once they're the only ones left. It is not the rule for the whole line.

Computer Science · Variables in expressions

Which line breaks the program?

A student wants Python to work out the total cost of 3 items at 4 each, then the change from 20. Every calculation looks fine. So which line causes the problem?

A student's program — which line goes wrong?

Exam line: Check every variable in an expression: has it been given a value on an earlier line?

Predict, then check

Modulo isn't just for leftover counters. It can also answer a yes/no question about a number.

A program stores 13 in number and then works out number % 2. What value comes out?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • An operator is a symbol or word that tells the computer to perform a specific calculation or action.
  • Python's arithmetic basics: + adds, - subtracts, * multiplies, / divides and ** is exponentiation.
  • An arithmetic expression results in a numeric value — score ** 2, for instance, is score to the power of two.
  • Have a goYour friend Jas is certain that 4 ** 2 is 8, "because two stars just means times two". Is Jas right? And what's the real value?

    Not right. 4 ** 2 is 16.

    ** is exponentiation, so it's 4 to the power of two (4 × 4). Times two would be 4 * 2 — the single star — which is where Jas's 8 comes from.

  • Python follows the order of operations: brackets, indices, multiplication and division, then addition and subtraction, which go left to right.
  • Have a goNo calculator, no peeking: what does 20 - 4 * 3 + 1 evaluate to in Python?

    9

    Multiplication first: 4 * 3 = 12. Then - and + left to right: 20 - 12 = 8, then 8 + 1 = 9. Going strictly left to right would give 49.

  • Expressions can use values stored in variables, but each variable must be assigned a value before it's used.
  • Real division, /, divides the entire value, so there's no remainder: 14 / 3 gives 4.666…, a decimal.
  • Integer division (also called floor division), //, discards any remainder and leaves a whole number: 14 // 3 gives 4.
  • Modulo (MOD), %, returns only the remainder: 14 % 3 gives 2, because 3 goes into 14 four times with 2 over.
  • Have a goYour turn: what do 23 // 4 and 23 % 4 give?

    5 and 3.

    4 goes into 23 five times (that's 20), with 3 over. // keeps the 5 and % keeps the 3. If you said 5.75, that's what / would give.

  • Sharing things out? Use // and % together: // says how many each person gets, % says how many are left.
  • Modulo can check for odd numbers too: when number % 2 evaluates to 1, the number is odd.

The big picture

Python does arithmetic with +, -, *, / and **, and it has three ways to divide: / divides the entire value, // throws the remainder away, and % keeps only the remainder. It works out a line in a fixed order (brackets, indices, multiplication and division, then addition and subtraction), and any variable in an expression needs a value first.

Key points

1/ divides the entire value, // keeps only the whole number, and % keeps only the remainder.
2Brackets, indices, multiplication and division, then addition and subtraction. Not simply left to right.
3Give every variable a value before an expression uses it.
4** is exponentiation, and a number % 2 that evaluates to 1 is odd.

Worked example

Problem

A program sets score = 3 and bonus = 4, then runs total = (score + bonus) * 2 ** 2 - 5. Work out the value of total, one step at a time, in Python's order.

⚠ Watch out

Thinking there's only one kind of division, or that Python works along a line from left to right. It feels natural — it's how you read. But /, // and % give different values, and the order of operations decides what gets worked out first.

🧠

Memory hook

One division, three operators: / is the full answer, // is how many each person gets, and % is the counters still sitting on the table.

✓

Check yourself

Cover the page. A coach shares 40 bibs between 6 teams. Write the Python expression for the bibs each team gets and the one for the bibs left over, then work out both values.

Flashcards

(12)
What is an operator?
A symbol or word that instructs the computer to perform a specific calculation or action.
What is an arithmetic expression?
An expression that results in a numeric value.
In Python, what do +, -, * and / do?
+ adds, - subtracts, * multiplies and / divides.
What does ** do, and what does score ** 2 mean?
** is exponentiation. score ** 2 is the value of score to the power of two.
In what order does Python work out an expression?
Brackets, then indices, then multiplication and division, then addition and subtraction.
+ and - sit side by side in an expression. Which goes first?
Neither outranks the other — Python reads them from left to right.
What must happen to a variable before an expression uses its value?
It must already have been assigned a value, on an earlier line.
What is real division, and what is its Python symbol?
Division of the entire value, so there's no remainder and the result can be a decimal. Python uses /.
What does integer (floor) division do, and what is its Python symbol?
It discards any remainder, leaving only a whole number. Python uses //.
What does modulo (MOD) return, and what is its Python symbol?
Only the remainder of a division. Python uses %.
Sharing things out: which two operators work as a pair, and what does each tell you?
// tells you how many each person gets; % tells you how many are left over.
How can modulo test whether a number is odd?
Work out number % 2. If it evaluates to 1, the number is odd.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 25 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.