AQA GCSE Computer Science June 2024 Paper 1, Question 9: records

AQA 8525 June 2024 Paper 1, Question 9: say what a data structure is, complete a RECORD definition for a book, and write pseudo-code that outputs the name of the more expensive of two books, or Neither. Worked through, with records in Python to run.

Past paper questionAQA 8525/1BJune 2024 Paper 17 marksComplete the algorithm

Question 9 of the AQA GCSE Computer Science Paper 1 sat on 15 May 2024 (8525/1B, the Python paper) is about records: a multiple choice (1 mark), a record definition with gaps (3 marks), and an algorithm in pseudo-code that compares two records (3 marks).

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.

Part 1: what is a data structure?

An organised collection of values. Arrays and records are data structures. A single whole number is not, and neither is "all the data in a program".

Part 2: complete the record definition

The algorithm defines a record called Book with the fields bookName, author and price, then makes two books. The four gaps are:

Gap Answer Why
after RECORD Book the name of the record definition
the second field author the question lists the three fields
the type of price Real 9.99 has a decimal part
the line for B2 Book a new record is made from the definition, exactly as B1 is

All four right is 3 marks, three right is 2, two right is 1. The paper says an item can be used more than once, and Book is.

Part 3: the most expensive book

Compare the two prices. Output the name of the dearer book, or Neither if the prices are equal. Fields are reached with a dot.

IF B1.price > B2.price THEN
    OUTPUT B1.bookName
ELSEIF B1.price < B2.price THEN
    OUTPUT B2.bookName
ELSE
    OUTPUT "Neither"
ENDIF

One mark for selection with more than one condition. One for correct comparisons of the prices. One for the right output in every case. Any error caps it at 2.

Where the marks are lost

  • B2 in the last gap. B2 ← B2(...) makes no sense. The thing on the right is the record type.
  • String for price. You cannot compare prices stored as text in a sensible way.
  • Two branches only. IF ... ELSE outputs a book when the prices are equal. There are three cases, so three branches.
  • Outputting the price. The question asks for the book name.
  • Hard-coding the answer. OUTPUT "The Book Thief" is right for these two books only. The question says it must work for any values.
  • price.B1. It is record, dot, field: B1.price.

Run it

Python has no RECORD, but a small class does the same job: a named bundle of fields, reached with a dot. Change the prices and run it again.

With the prices from the paper it prints The Book Thief. Make both prices 6.55 and it prints Neither.
The program
from bugbot import *
connect()

class Book:
    def __init__(self, bookName, author, price):
        self.bookName = bookName
        self.author = author
        self.price = price

B1 = Book("The Book Thief", "M Zusak", 9.99)
B2 = Book("Divergent", "V Roth", 6.55)

if B1.price > B2.price:
    print(B1.bookName)
elif B1.price < B2.price:
    print(B2.bookName)
else:
    print("Neither")
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 are the answers to AQA GCSE Computer Science 2024 Paper 1 Question 9.2?

Book, author, Real and Book.

What is a record?

A data structure that groups related values of different data types under one name. Each value is a field with its own name and type, reached with a dot, such as B1.price.

What is the difference between a record and an array?

An array holds many values of the same data type, reached by index number. A record holds a fixed set of named fields, which can have different data types.

More from this paper

Every AQA 8525 question we have worked · Guide: Logic gates and truth tables explained

Learn it step by step

  1. F3.6 Records Strings, lists and records
  2. F2.3 else, elif and Boolean operators 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.