GCSE · Computer Science · Eduqas · Spec C500QS

Lists, tuples and dictionaries

Three containers, one big choice: can it change, and do you find things by position or by name?

Computer Science · Python lists

Follow one list: call it before it changes

Call each marked step before the table shows it. Nothing is run: every value is the lesson’s, checked against Python 3.

scores = [12, 7, 9]
scores[1] = 8
scores.append(10)
scores.insert(0, 5)
scores.extend([3, 4])
scores.remove(9)
last = scores.pop()
del scores[0]
print(len(scores))
print(scores[-1])
print(8 in scores)
for s in scores:
print(s)
scoreslasts
[12, 7, 9]

Step 1. The list is made. Index 0 holds 12, index 1 holds 7, index 2 holds 9. This first row is worked for you.

Step 1 of 15Called right: 0 of 9

Computer Science · Three structures

List, tuple, dictionary: tick what each one has

Tick every property each structure has. Decide before you press check.

List
Tuple
Dictionary

Exam line: Compare using both questions: can it be changed after it is made, and is an item found by index position or by key.

Computer Science · Dictionaries

Which idea is yours?

ages = {"Ali": 15, "Beth": 14}. Four learners each say something about it.

Which is closest to what you think right now?
How sure are you?

Computer Science · Reading error messages

Press Run, read the message, fix the line

This program makes a list, a tuple and a dictionary, then uses them. It has more than one problem and Python reports them one at a time. Press Run, read what Python says, then choose how to fix the line it points at.

Python
  1. scores = [12, 7, 9]
  2. point = (3, 4)
  3. ages = {"Ali": 15, "Beth": 14}
  4. print(scores[3])
  5. scores.remove(5)
  6. point[2] = 5
  7. print(ages["Cal"])
  8. lookup = {[1, 2]: "start"}
  9. print(point)

Every message and output here is what Python 3 gives for this exact code.

Predict, then check: a grid

grid is a list of lists. Commit to row-then-column before you look.

grid = [[1, 2, 3], [4, 5, 6]]. What does print(grid[1][2]) show?

Computer Science · Choosing a structure

Which structure fits the job?

Sort each job into list, tuple or dictionary. Decide first, then read the reason.

Still to sort

List (0)

Changes while the program runs; items found by position.

Where the line is: If nothing needs to change, a tuple is safer. If values are found by name, use a dictionary.

Tuple (0)

A fixed group of values that should not change.

Where the line is: If items must be added, removed or updated, a tuple cannot do it.

Dictionary (0)

Each value is found by a meaningful key, such as a name.

Where the line is: If position is what identifies the item, a list is the better fit.

6 of 6 still to sort.

Exam line: Justify the choice from the job: does it change while the program runs, and is each value found by position or by a meaningful key?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Three ways to hold a collection in Python, and how to pick the right one.

What you need to know

  • A list is an ordered collection you can change after making it. Write its items in square brackets: scores = [12, 7, 9].
  • Each item has an index, and indexes start at 0. So scores[0] is the first item and scores[-1] is the last. An index outside the list raises an IndexError.
  • Have a goSam says the first item of scores = [12, 7, 9] is scores[1], and is very sure. What does scores[1] actually give?

    7, the second item

    Indexes start at 0, so index 1 is the second item. The first item, 12, is scores[0].

  • Change an item by assigning to its index: scores[1] = 8. Delete one with del scores[0]. Add one to the end with append(item).
  • insert(index, item) puts an item at that position and moves later items along by one. extend(other) adds every item of another collection to the end.
  • remove(value) deletes the first item equal to value, or raises a ValueError. pop() removes and returns the last item; pop(index) does the same at that index.
  • len(), in and a for loop all work on lists and tuples. len() also counts the key-value pairs in a dictionary.
  • A tuple is ordered but cannot be changed. Round brackets: point = (3, 4). Assigning to one of its items raises a TypeError.
  • Have a gopoint = (4, 8, 15). Predict what len(point) gives, and whether 8 in point is True or False.

    3, and True

    len counts the items, and in tests whether a value is an item of the tuple, giving True or False.

  • A dictionary holds key: value pairs in curly brackets: ages = {"Ali": 15}. Look a value up by key, ages["Ali"], not by index. A missing key raises a KeyError.
  • Keys are unique: assigning to an existing key replaces its value, and a new key adds a pair. del ages["Beth"] removes a pair.
  • Have a goages = {"Ali": 15, "Beth": 14}. After ages["Cal"] = 16 runs, what does len(ages) give?

    3

    Cal is a new key, so a new key-value pair is added and len counts three pairs.

  • Choose a list for a collection that changes, a tuple for a fixed group of values, and a dictionary when values are found by a meaningful key.

The big picture

Lists, tuples and dictionaries are three ways to hold a collection of values in Python 3. A list is ordered and can be changed. A tuple is ordered but cannot be changed. A dictionary holds key-value pairs and is looked up by key. Pick between them by asking whether the data must change and whether items are found by position or by a key.

Key points

1List: ordered, changeable, square brackets, found by index (from 0, with -1 for the last).
2Tuple: ordered, cannot be changed, round brackets; assigning to an item raises a TypeError.
3Dictionary: key-value pairs in curly brackets, looked up by key; keys are unique and must be unchangeable.
4Each misuse has its own error: IndexError, ValueError, TypeError, KeyError.
5Choose by the job: changes while running, fixed values, or found by a meaningful key.

Worked example

Problem

Trace this program and write down everything it prints. stock = {"apple": 5, "pear": 2} stock["pear"] = 7 stock["fig"] = 4 del stock["apple"] print(len(stock)) print(stock["pear"]) print("apple" in stock)

⚠ Watch out

Thinking the first item is at index 1. Indexes start at 0, so a list of three items has indexes 0, 1 and 2, and index 3 raises an IndexError.

🧠

Memory hook

Square brackets, squishy list. Round brackets, rock-solid tuple. Curly brackets, call it by name.

✓

Check yourself

names = ["Ana", "Ben", "Cy"]. Then names.insert(1, "Di") runs. Without running anything: what does print(names[-1]) show, and what does names[1] hold?

Flashcards

(14)
Which brackets make a list, a tuple and a dictionary?
List: square [ ]. Tuple: round ( ). Dictionary: curly { } with key: value pairs.
What do scores[0] and scores[-1] give?
The first item and the last item of the list.
What does an index outside a list or tuple raise?
An IndexError.
append vs insert vs extend
append adds one item to the end. insert puts an item at a given position and moves later items along. extend adds every item of another collection to the end.
remove(value) vs pop() vs del scores[0]
remove deletes the first item equal to the value (ValueError if none). pop removes AND returns the last item, or the one at an index. del deletes the item at an index.
What does len() count?
The items in a list or tuple, and the key-value pairs in a dictionary.
What does in test for lists and tuples? And for a dictionary?
Lists and tuples: whether a value is an item. Dictionaries: whether a key is in the dictionary.
How do you write a tuple with only one item?
With a trailing comma: (5,).
How can you get a tuple that holds one more value?
Join tuples with +, such as point + (5,). That creates a new tuple and leaves the original unchanged.
How is a 2D array stored with lists, and how is an item reached?
As a list of lists. An item is reached by two indices: grid[row][column].
What happens with ages["Zed"] if "Zed" is not a key? And ages.get("Zed")?
Square brackets raise a KeyError. get returns None, or a default value if you state one.
What cannot be used as a dictionary key?
A list, or a tuple that contains a list. Keys must be unchangeable, like strings, numbers or tuples of unchangeable items.
What does a for loop over a dictionary visit? What do keys(), values() and items() give?
It visits the keys. keys() gives the keys, values() the values, items() the key-value pairs.
Can one list, tuple or dictionary hold different data types?
Yes. Lists, tuples and dictionaries can hold items of different data types.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 16 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.