GCSE · Computer Science · AQA · Spec 8525
Addition (arithmetic operator)
Here's a weird one: a line of code can work out exactly the right answer and still leave your total unchanged. Soon 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 ← 02 points ← 103 score ← score + points4 points ← 255 OUTPUT score + points6 score ← score + points7 score ← score + 58 OUTPUT score
| score | points |
|---|---|
| 0 |
Output
Step 1: The game starts. score is set to 0. Nothing has been added yet.
Press Next to run one line. Say what each variable holds BEFORE you look.
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 values together to give their total.
- Each side of + can be a literal (a number typed straight into the code, like 5) or a variable, like price.
- So you can add two literals, two variables, or one of each: 3 + 4, a + b, price + 2.
Have a goSort these three: 7 + 3, cost + tax, cost + 3. Which is two literals, which is two variables, and which is a mix?
7 + 3: two literals. cost + tax: two variables. cost + 3: a mix.
A literal is a number typed into the code; a name like cost or tax is a variable, so it doesn't matter that cost + 3 looks 'half number'.
- Working out a sum doesn't keep it. To use it later, store it with an assignment: total ← price + 2.
Have a gocoins holds 50. Your mate's program prints coins + 10 on screen, and they cheer: 'coins is 10 bigger now!' What does coins actually hold?
Still 50. The 60 was only shown on screen.
The sum was worked out, but no assignment stored it, so coins never got a new value. Celebration slightly premature.
- Python writes assignment with =, so that same line becomes total = price + 2.
- In an assignment, the right-hand side is worked out first, using each variable's current value.
- Then the answer goes into the variable on the left, replacing whatever it held.
- Variables on the right of the arrow are only read. They don't change.
Have a goa holds 4 and b holds 6. Then c ← a + b runs. Which variables change, and what does c hold?
Only c changes. It holds 10; a is still 4 and b is still 6.
Using a and b in the sum only reads them; the only variable that gets a new value is the one on the left of the arrow.
- 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
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. It looks finished. It isn't: 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?
What can go either side of + ?
What is an assignment?
After x ← y + 2 runs, has y changed?
Why isn't total ← total + 1 an impossible equation?
What is a running total?
What happens to a sum that is output but never stored?
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 postedMore AQA GCSE Computer Science topics
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 28 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.