GCSE · Computer Science · AQA · Spec 8525

Addition (arithmetic operator)

A line of code can work out exactly the right answer and still leave your total unchanged. By the end of this page, you'll spot that line in seconds.

Programming · Addition

Follow the score, one line at a time

The arrow ← means 'store the value on the right in the variable on the left'. A new value appears in the table only when a line stores one.

Line 5 works out 35. Before you step past it, predict: what does score hold straight afterwards?

1 score ← 0
2 points ← 10
3 score ← score + points
4 points ← 25
5 OUTPUT score + points
6 score ← score + points
7 score ← score + 5
8 OUTPUT score
scorepoints
0

Output

 

Step 1: The game starts. score is set to 0 — nothing has been added yet.

1 / 8

Press Next to run one line. Say what each variable holds BEFORE you look.

Step 1 of 8: The game starts. score is set to 0 — nothing has been added yet..

Exam line: When you trace code, ask of every line: which variable, if any, is on the left of the arrow? That is the only one that can change.
Watch out: On line 5, watch the table as well as the screen. Something appears on screen — but does anything get stored?

What do you think?

The line that looks impossible

A program has just stored 7 in score. The very next line is score ← score + 5.

What does that line do? Pick the idea closest to what you think right now.
How sure are you?

Exam line: Read x ← x + 5 as 'x becomes its current value plus 5'.

Spot the bug

Where did the 3 go?

This program should add up three prices — 4, 3 and 2 — and output the total, 9. It outputs 6. Which line is wrong?

A student's program — which line goes wrong?

Exam line: Every value you add into a total must be stored back into that total.

Your turn

Write the code for a cinema booking

A cinema program already stores the price of a ticket in ticketPrice and the price of popcorn in popcornPrice. Write pseudo-code or program code that adds a booking fee of 2 to ticketPrice and stores the result in a variable called cost, then adds popcornPrice to cost, and then outputs cost. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

Exam line: One idea per line: add, store, output. Each one can earn credit on its own.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Working out a sum is only half the job. The other half is putting the answer somewhere.

What you need to know

  • The + operator adds two values to give a result. The values can be literals (numbers typed straight into the code, like 5), variables (like price), or one of each.
  • Working out a sum does not keep it. To use the result later, store it in a variable with an assignment, e.g. total ← price + 2. (In Python, assignment is written with =.)
  • In an assignment, the right-hand side is worked out first, using each variable's current value. The result is then stored in the variable on the left, replacing whatever it held.
  • A running total starts at 0 and grows one value at a time with total ← total + value.

The big picture

The + operator adds values in a program — two literals, two variables, or one of each — to give a result. That result is only kept if an assignment stores it in a variable. A running total starts at 0 and grows with lines like total ← total + price, where the right-hand side is worked out first and then stored.

Key points

1+ adds literals, variables, or a mix of both.
2No assignment, no stored result — outputting a sum does not change any variable.
3total ← total + 5 is an instruction, not an equation: right side first, then store.
4Only the variable on the left of the arrow changes; variables on the right are just read.
5Set a running total to 0 before you start adding into it.

Worked example

Problem

An app tracks a swimmer's laps. Trace this program and give the values of laps and bonus after each line. laps ← 3 bonus ← laps + 4 laps ← laps + bonus bonus ← bonus + 1

⚠ Watch out

Writing a sum without storing it — such as OUTPUT total + price — and then expecting total to have changed. Only a line that assigns into total changes total.

🧠

Memory hook

Work it out on the right, put it away on the left. A sum that's never put away is lost.

✓

Check yourself

x holds 8. What does x hold after x ← x + x + 1 runs? (Answer: 17 — work out 8 + 8 + 1 first, then store it in x.)

Flashcards

(7)
What does the + operator do in a program?
It adds two values together to give a result.
What can go either side of + ?
A literal (like 3), a variable (like price), or one of each: 3 + 4, a + b, price + 2.
What is an assignment?
An instruction that stores a value in a variable, e.g. total ← 5. Python writes it total = 5.
After x ← y + 2 runs, has y changed?
No. y is only read on the right-hand side. Only the variable on the left changes.
Why isn't total ← total + 1 an impossible equation?
It's an instruction, not a claim that two things are equal. It means 'total becomes its current value plus 1'.
What is a running total?
A variable that starts at 0 and has each new value added into it in turn, with total ← total + value.
What happens to a sum that is output but never stored?
It appears on screen and is then gone. No variable changes, so the program can't use it later.

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 30 September 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.