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] = 8scores.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)
| scores | last | s |
|---|---|---|
| [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.
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.
- scores = [12, 7, 9]
- point = (3, 4)
- ages = {"Ali": 15, "Beth": 14}
- print(scores[3])
- scores.remove(5)
- point[2] = 5
- print(ages["Cal"])
- lookup = {[1, 2]: "start"}
- 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.
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
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?
What do scores[0] and scores[-1] give?
What does an index outside a list or tuple raise?
append vs insert vs extend
remove(value) vs pop() vs del scores[0]
What does len() count?
What does in test for lists and tuples? And for a dictionary?
How do you write a tuple with only one item?
How can you get a tuple that holds one more value?
How is a 2D array stored with lists, and how is an item reached?
What happens with ages["Zed"] if "Zed" is not a key? And ages.get("Zed")?
What cannot be used as a dictionary key?
What does a for loop over a dictionary visit? What do keys(), values() and items() give?
Can one list, tuple or dictionary hold 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 postedMore Eduqas GCSE Computer Science topics
- Explaining test outcomes
- File handling: open a file
- File handling: read into a variable
- File handling: read into an array
- File handling: write to a file
- Iteration: condition and counter controlled loops
- Mathematical and logical operations in code
- Modular structuring with abstraction
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Selection in programs
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.