SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Edexcel 1CP2 · Topic 2 · 2.2b

Records as a
Data Structure

Fields · Mixed Data Types · Lists of Records · Dictionaries in Python

CSZoneEdexcel GCSE Computer Science 1CP2
What is a Record?

Grouping Related Data

A record is a collection of related data items called fields. Unlike an array (one data type), a record can store different data types in a single structure. Like a row in a database table.
Example: a student record might have fields: name (string), age (integer), grade (string), enrolled (boolean)
Each field has a name and a data type
Records in Python

Using Dictionaries as Records

student = {
  "name": "Emma",
  "age": 16,
  "grade": "A",
  "enrolled": True
}

print(student["name"]) # Emma
student["age"] = 17 # update a field
Lists of Records

Storing Multiple Records

students = [
  {"name": "Alice", "grade": "A"},
  {"name": "Bob", "grade": "B"},
  {"name": "Carol", "grade": "A"}
]

for s in students:
    print(s["name"], s["grade"])
A list of dictionaries is a common way to model a table (like a database) in Python
Exam Practice

Have a go at this question

Edexcel-style question
Describe what is meant by a record data structure and explain one advantage over using an array to store the same data.
3 marks
A record stores related data about a single entity in multiple named fields [1]. Unlike an array, a record can hold fields of different data types in one structure [1] — for example, a student record can store a name (string), age (integer), and enrolled status (boolean) together [1].
Key Takeaways

What to Remember

Record = group of named fields, each with its own data type
Can hold mixed types — unlike arrays which store one type
In Python: records implemented as dictionaries; access with ["key"]
List of dicts = table of records — common pattern for database-style data