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 ← 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 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
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?
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 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.