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.

Past paper questionAQA 8525/1BJune 2024 Paper 16 marksTrace table

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 i column: 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 weeks columns: 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]. DIV gives a whole number. 30 DIV 7 is 4.
  • Rounding up. 48 / 7 is 6.86, and 48 DIV 7 is 6, not 7. DIV always rounds down.
  • Adding days and sales the wrong way. It is days[0] + sales[0], then days[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.

It prints the three passes and then a total of 12. Change DIV 7 to / 7 in your head: 4.29 + 6.86 + 2.29 is 13.4 weeks, so rounding down loses more than a week.
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)
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 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

Every AQA 8525 question we have worked · Guide: Trace tables explained

Learn it step by step

  1. F13.2 Trace tables Exam preparation
  2. F3.4 Iterating over a list Strings, lists and records
  3. F1.9 Arithmetic operators Programming basics
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.