New
New
Year 11
OCR

Records and dictionaries

I can create a record using a dictionary in Python.

New
New
Year 11
OCR

Records and dictionaries

I can create a record using a dictionary in Python.

These resources will be removed by end of Summer Term 2025.

Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.

These resources were created for remote use during the pandemic and are not designed for classroom teaching.

Lesson details

Key learning points

  1. Data structures are used to store data in an organised and accessible way.
  2. A record is an example of a data structure.
  3. A record allows you to store a collection of attributes for a single entity.
  4. Python does not have a native data structure for a record.
  5. Instead, you can use a different data structure called a dictionary to represent a record.

Keywords

  • Record - a collection of attributes for a single entity

  • Entity - an entity is a single object, place, person or thing

  • Attribute - properties or characteristics of an entity

  • Dictionary - a data structure that involves creating data pairings that can be located using a key

  • Key - used to identify each attribute held in the dictionary

Common misconception

There is no way to store multiple records in one data structure in Python.

If you want to use multiple records in a database, then you can add multiple dictionaries to a list.


To help you plan your year 11 computer science lesson on: Records and dictionaries, download all teaching resources for free and adapt to suit your pupils' needs...

There is a lot of new terminology in this lesson that learners may not be familiar with. Ensure learners are confident with the meaning of each keyword as you progress through the lesson. Consistent and accurate use of terminology will help pupils gain confidence of their correct usage.
Teacher tip

Equipment

All pupils requires access to devices that can edit and run Python programs. Starter code files are available to copy or use directly via the Raspberry Pi Code Editor.

Licence

This content is © Oak National Academy Limited (2025), licensed on Open Government Licence version 3.0 except where otherwise stated. See Oak's terms & conditions (Collection 2).

Lesson video

Loading...

6 Questions

Q1.
Which of the following correctly defines a list in Python?
{1, 2, 3, 4}
(1, 2, 3, 4)
Correct answer: `["apple", "banana", "cherry"]`
"apple", "banana", "cherry"
Q2.
Match the list operation with its description.
Correct Answer:`append()`,adds an item to the end of a list
append()
- 

adds an item to the end of a list

Correct Answer:`pop()`,removes an item from a list
pop()
- 

removes an item from a list

Correct Answer:`len()`,returns the number of items in a list
len()
- 

returns the number of items in a list

Q3.
What will be the output of the following code?
123
fruits = ["apple", "banana", "cherry"] fruits.append("orange") print(fruits)
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords
["apple", "banana", "cherry"]
["orange", "apple", "banana", "cherry"]
Correct answer: `["apple", "banana", "cherry", "orange"]`
["orange", "apple", "banana", "cherry"]
Q4.
What does the
.upper()
method do in Python?
Correct answer: converts all letters in a string to uppercase
converts all letters in a string to lowercase
removes spaces from a string
reverses the string
Q5.
What will be the output of the following code?
12
word = "PYTHON" print(word[2])
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords
P
Y
Correct answer: T
H
O
Q6.
Strings can hold letters, numbers, and symbols, and they must be enclosed in .
Correct Answer: quotes, "", speech marks, "

6 Questions

Q1.
What is a record in programming?
a single piece of data
Correct answer: a collection of attributes for a single entity
a type of loop in Python
a function that modifies dictionaries
Q2.
What is an attribute in a record?
Correct answer: a property or characteristic of an entity
a type of variable in Python
a function that retrieves data
a key used to access lists
Q3.
What will be the output of the following code?
12
player = { "username" : "rockstar", "password" : "6goatsEating", "score" : 5328 } print(player["username"])
Code colour

When programmers write code, they use a special tool called an IDE (Integrated Development Environment). In an IDE, different colours are used to help programmers understand the code:


  • • Blue - numbers and boolean values
  • • Green - strings
  • • Purple - keywords
Correct answer: rockstar
6goatsEating
5328
username
Q4.
Match the keyword to the description.
Correct Answer:record,a collection of attributes for a single entity

a collection of attributes for a single entity

Correct Answer:entity,a single object, place, person or thing

a single object, place, person or thing

Correct Answer:attribute,properties or characteristics of an entity

properties or characteristics of an entity

Correct Answer:dictionary,a data structure that involves creating data pairings

a data structure that involves creating data pairings

Correct Answer:key,used to identify each attribute held in the dictionary

used to identify each attribute held in the dictionary

Q5.
How is a record typically represented in Python?
using a list
using a tuple
Correct answer: using a dictionary
using a function
Q6.
How can you modify a value in a dictionary?
Correct answer: by reassigning a value using the key, e.g. `player["score"] = 9000`
by using the
append()
function
by using the
update()
function only
dictionaries cannot be modified