AQA GCSE Computer Science June 2024 Paper 1, Question 8: the three array trace table
AQA 8525 June 2024 Paper 1, Question 8: trace a FOR loop that adds two arrays item by item, stores each total DIV 7 in a third array, and outputs the sum. The full table, the six marks explained, and the algorithm to run.
Question 8 of the AQA GCSE Computer Science Paper 1 sat on 15 May 2024 (8525/1B, the Python paper) is a 6 mark trace table. It has three arrays in it, and one of them has a column for each of its elements.
We do not copy the exam paper here. Open it beside this page: AQA June 2024 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.
The question in short
Three arrays: days holds 10, 15, 4. sales holds 20, 33, 12. weeks holds 0, 0, 0.
A loop runs i from 0 to 2. On each pass, daysTotal becomes days[i] + sales[i], and weeks[i] becomes daysTotal DIV 7. After the loop, weeksTotal is the three elements of weeks added up, and it is output.
DIV is integer division: divide and throw the remainder away.
Work it through
i = 0. daysTotal is 10 + 20 = 30. 30 DIV 7 is 4 (four sevens are 28). So weeks[0] is 4.
i = 1. daysTotal is 15 + 33 = 48. 48 DIV 7 is 6 (six sevens are 42). So weeks[1] is 6.
i = 2. daysTotal is 4 + 12 = 16. 16 DIV 7 is 2. So weeks[2] is 2.
After the loop. weeksTotal is 4 + 6 + 2 = 12.
The finished trace table
| i | daysTotal | weeks[0] | weeks[1] | weeks[2] | weeksTotal |
|---|---|---|---|---|---|
| 0 | 0 | 0 | |||
| 0 | 30 | 4 | |||
| 1 | 48 | 6 | |||
| 2 | 16 | 2 | |||
| 12 |
Where the six marks are
- the
icolumn: 0, 1, 2; - the first value of
daysTotal: 30; - the rest of
daysTotal: 48, 16; - the second value in the
weeks[0]column: 4; - the rest of the
weekscolumns: 6 and 2; weeksTotal: 12, and nothing else in that column.
Any error caps you at 5. The total is marked on what you wrote in the weeks columns, so a slip earlier does not cost this mark as well.
Where the marks are lost
- 4.28 or 4.3 in
weeks[0].DIVgives a whole number. 30 DIV 7 is 4. - Rounding up. 48 / 7 is 6.86, and 48 DIV 7 is 6, not 7.
DIValways rounds down. - Adding
daysandsalesthe wrong way. It isdays[0] + sales[0], thendays[1] + sales[1]: matching positions, not neighbours. - A running total in
weeksTotal. It is worked out once, after the loop.
Run it
The algorithm in Python, printing a row for every pass. // is Python's DIV.
The program
from bugbot import *
connect()
days = [10, 15, 4]
sales = [20, 33, 12]
weeks = [0, 0, 0]
print("i daysTotal weeks")
for i in range(0, 3):
daysTotal = days[i] + sales[i]
weeks[i] = daysTotal // 7
print(i, daysTotal, weeks)
weeksTotal = weeks[0] + weeks[1] + weeks[2]
print("weeksTotal", weeksTotal)
forward(60, distance=weeksTotal)
Questions
What is the answer to AQA GCSE Computer Science 2024 Paper 1 Question 8?
i is 0, 1, 2. daysTotal is 30, 48, 16. weeks[0] becomes 4, weeks[1] becomes 6 and weeks[2] becomes 2. weeksTotal is 12.
What does DIV mean?
Integer division: the whole number of times one number goes into another, with the remainder ignored. 30 DIV 7 is 4. In Python it is written //.
How do I show an array in a trace table?
Give each element its own column, headed with its index. Write a new value in an element's column only when that element changes.
More from this paper
- Question 1: LEN, POSITION, a data type, assignment, and a two line program 6 marks
- Question 2: Follow an IF, ELSEIF chain with NOT, OR, AND and MOD 5 marks
- Question 3: random.randrange, a test plan, and a syntax and a logic error 6 marks
- Question 5: The output of a nested IF for three pairs of inputs 3 marks
- Question 6: Essay marks with penalties for late essays, never below 0 7 marks
Every AQA 8525 question we have worked · Guide: Trace tables explained
Learn it step by step
- F13.2 Trace tables Exam preparation
- F3.4 Iterating over a list Strings, lists and records
- F1.9 Arithmetic operators Programming basics
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.