AQA GCSE Computer Science June 2025 Paper 1, Question 9: which algorithms total the array?

AQA 8525 June 2025 Paper 1, Question 9: five pseudo-code algorithms try to total the five values of an array. Two work and three do not: an out of range loop, a loop that never starts and a loop that never ends. Each one explained, with all five to run.

Past paper questionAQA 8525/1BJune 2025 Paper 12 marksRead the code

Question 9 of the AQA GCSE Computer Science Paper 1 sat on 12 May 2025 (8525/1B, the Python paper) shows five short algorithms, A to E. Each tries to add up the array 44, 1, 2, 14, 68. You tick whether each one works. Three right is 1 mark. All five right is 2.

We do not copy the exam paper here. Open it beside this page: AQA June 2025 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.

How to check a loop

Ask three questions. Where does it start? (The first index is 0.) Where does it stop? (The last index is 4.) Does something change on every pass, so that it can stop?

The five algorithms

A works. A WHILE loop with counter from 0 up to 4. It copies counter into index, which is unnecessary but harmless, adds numbers[index], and adds 1 to counter. Total 129.

B works. FOR a ← 0 TO LEN(numbers) - 1 is 0 to 4: every index, once. This is the tidy version.

C does not work. FOR a ← 1 TO 7 starts at 1, so it misses 44. Then it runs on to index 5, 6 and 7, which do not exist.

D does not work. total starts at 0 and the loop is WHILE total > 0. Is 0 greater than 0? No. The loop never starts, and the output is 0. (If it did start, it would use total as an index, which makes no sense either.)

E does not work. x starts at 1, and nothing inside the REPEAT loop changes it. x never reaches 5, so the loop never ends. It adds numbers[1] for ever.

The answers

A B C D E
Totals the five values
Does not

Where the marks are lost

  • Marking A wrong because it looks clumsy. Clumsy is not broken. Trace it.
  • Marking C right because 1 to 7 "covers" five items. Indexes start at 0 and end at 4.
  • Missing that D never runs. Always test a WHILE condition with the starting values.
  • Missing that E has no step. A FOR loop moves its own counter. WHILE and REPEAT loops do not: you have to do it yourself.

Run it

All five in Python. C stops with an index error. D prints 0. E would run for ever, so this version gives up after 20 passes and says so.

A and B print 129. C crashes out of range. D prints 0 because its loop never starts. E is stopped after 20 passes with x still 1.
The program
from bugbot import *
connect()

numbers = [44, 1, 2, 14, 68]

counter = 0
total = 0
while counter < 5:
    index = counter
    total = total + numbers[index]
    counter = counter + 1
print("A", total)

total = 0
for a in range(0, len(numbers)):
    total = total + numbers[a]
print("B", total)

total = 0
try:
    for a in range(1, 8):
        total = total + numbers[a]
    print("C", total)
except IndexError:
    print("C index out of range when a =", a)

total = 0
while total > 0:
    total = total + numbers[total]
print("D", total)

total = 0
x = 1
passes = 0
while True:
    total = total + numbers[x]
    passes = passes + 1
    if x == 5 or passes == 20:
        break
print("E stopped after", passes, "passes with x =", x)
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is the answer to AQA GCSE Computer Science 2025 Paper 1 Question 9?

A and B total the five values. C, D and E do not.

What causes an infinite loop?

A condition-controlled loop whose condition can never change, usually because the variable in the condition is not updated inside the loop.

Why might a while loop never run?

A while loop tests its condition before the first pass. If the condition is false to begin with, the body is skipped completely.

More from this paper

Every AQA 8525 question we have worked

Learn it step by step

  1. F3.4 Iterating over a list Strings, lists and records
  2. F6.4 Debugging logic errors Robust programs
  3. F2.6 Condition-controlled loops: while Decisions and loops
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by AQA, and the question paper and mark scheme remain AQA's copyright. Read them on AQA's site with the links on this page.