GCSE · Computer Science · AQA · Spec 8525

Multiplication (arithmetic operator)

In maths, 2n obviously means 2 times n. Type 2n into a program and the computer has no idea what you mean. One tiny symbol fixes it: the *.

Computer Science · Arithmetic operators

Would the computer multiply this?

Pick a line, then decide: will the computer read it as a multiplication, or not?

Still to sort

Multiplies (0)

Doesn't multiply (0)

Where the line is: Ask yourself: is there an actual * between the two values? If a human would have to 'just know' it means times, the computer won't.

9 of 9 still to sort.

Every line here is someone's attempt to multiply. You've written most of these in maths lessons — now test each habit against what code accepts.

Computer Science · Algorithms

Trace table — dry run the code

Painting four square walls, two coats each. The arrow ← means 'store the value on the right in the variable on the left'. Predict each new value before you step.

1side ← 6
2area ← side * side
3walls ← 4
4paint ← area * walls
5paint ← paint * 2
6OUTPUT paint
side
area
walls
paint
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

Predict, then check

Does the computer just read left to right, or does it follow an order rule?

A program runs the line: answer ← 2 + 3 * 4. What gets stored in answer?

Your turn

Turn a maths formula into code

The perimeter of a rectangle is P = 2(l + w). Write it as one line of code that stores the perimeter in a variable called perimeter, using variables called length and width.

  1. P = 2(l + w)Start with the maths. Hunt for the hidden multiplication: the 2 is touching the bracket, which in maths means 2 times the whole bracket.
  2. missing step
Which line is step 2?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Maths lets you hide the times sign. Code needs to see it.

What you need to know

  • Pseudocode and languages like Python write multiplication with one symbol: *, the asterisk.
  • The maths times sign × isn't an operator in code, so price × quantity won't run.
  • Have a goYour mate types total ← 5 × price, gets an error, and announces the computer is broken. What's the one-character fix?

    Swap × for *: total ← 5 * price.

    The computer's fine — × just isn't a code operator, so it can't read the line until the asterisk goes in.

  • Neither is the letter x. To the computer it's just a letter — it could even be a variable's name.
  • Every multiplication has to be written. Code never assumes one, so 2n and 2(a + b) are errors.
  • Letters side by side make one name: ab is a variable called ab, not a times b.
  • Have a goHow many multiplications are hiding in 3ab, and how would you write it in code?

    Two: 3 * a * b.

    Each hidden multiplication needs its own *. Writing 3 * ab only fixes one — it multiplies 3 by a single variable called ab.

  • Spaces around * are optional. price*quantity and price * quantity do exactly the same job.
  • In total ← price * quantity, the right-hand side is worked out first, then stored in the variable on the left.
  • A variable can be multiplied and stored back into itself: the old value is used, then replaced.
  • Have a gocount holds 7. The line count ← count * 3 runs. What does count hold now?

    21

    The right-hand side uses the old 7 first: 7 * 3 = 21. Then 21 replaces the 7 — count doesn't stay at 7 or keep both values.

  • * happens before +, just like in maths. Brackets make the addition go first.
  • Turning a formula into code? Add a * for every hidden multiplication and keep any brackets it needs.

The big picture

In code, multiplication is written with the * operator, and it always has to be written: 2n, 2(a + b), ab, a × b and a x b don't multiply. In an assignment such as cost ← price * quantity, the right-hand side is worked out first and the result is stored in the variable on the left. * is done before + unless brackets change the order.

Key points

1Write 2 * n, never 2n.
2Spaces around * are optional — the * is not.
3x ← x * 2 takes the current value of x, doubles it, and stores the answer back in x.
42 * (a + b) and 2 * a + b are different: the brackets decide what gets doubled.

Worked example

Problem

A taxi firm's fare, in pounds, is C = 3 + 2d, where d is the distance in miles. Write this as a line of code that stores the fare in a variable called fare, then work out what is stored when distance holds 5.

⚠ Watch out

Writing multiplication the maths way: 2n instead of 2 * n, or 2(a + b) instead of 2 * (a + b). It looks convincing, because maths lets you do it. But the computer won't fill in a missing *, and it reads ab as one variable called ab.

🧠

Memory hook

No star, no multiply. If you can't see the *, neither can the computer.

✓

Check yourself

Rewrite y = 4x as a line of code, then say what is stored in y when x holds 3. (Answer: y ← 4 * x, which stores 12.)

Flashcards

(7)
What symbol means multiply in code?
* — the asterisk. Not ×, and not the letter x: neither of those is an operator in code.
Why doesn't 2n work in code?
There's no operator between the 2 and the n, and the computer won't assume one. Write 2 * n.
What does the computer make of ab?
One variable name, ab — not a times b. Write a * b.
How do you write 2(a + b) in code?
2 * (a + b). Add the *, keep the brackets.
In total ← price * quantity, what happens first?
The right-hand side is worked out, then the result is stored in total.
What does x ← x * 2 do?
Takes the value x holds now, doubles it, and stores the answer back in x, replacing the old value.
Which goes first in code: * or +?
*. Use brackets if you need the + to happen first.

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 AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)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 29 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.