← VCE Software Development U3O1

Choosing a data structure

Pick the structure by how you use the data: a list for an ordered collection, a dict for lookup by key, and a tuple for a fixed group of values that should not change.

Understanding Choosing a data structure in VCE Software Development U3O1

What it does: Round brackets make a tuple. An x, y point is a fixed pair of values that should not be changed. Each dictionary is one record with named fields, and the list keeps the records in order. A list is an ordered collection that can grow or change, which suits a series of scores. A dictionary lets you look up a value by its key, so phones["Mia"] gives the number straight away. Tuples are fixed, so there is no append(). A list is better when items are added or removed. Looking up a word by name and updating its count is a key lookup job, which dictionaries do best.

Common mistakes: Scores is an ordered collection that grows, so it needs a list. A tuple is fixed and has no append(), so line 2 would fail. It should be scores = [85, 92, 78]. A dictionary is looked up by key, not by position number. There is no key 0, so this causes a KeyError. It should be print(ages["Mia"]).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 98–113) and word search (Modules 72–113) and definitions worksheet (Modules 98–113) and word scramble (Modules 98–113).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
You need to store the scores of 30 students in the order they were entered. Which structure fits best?
A list: scores = [72, 85, 90]A tuple of student names stored as keys
Matches
colours = ("red", "blue") colours.append("green")
↓
A tuple cannot be changed, so append() causes an error. Use a list if the values need to grow.
Applying
Meanings
Term
list, dict, tuple
Meaning
Pick the structure by how you use the data: a list for an ordered collection, a dict for lookup by key, and a tuple for a fixed group of values that should not change.
Practice
point = (3, 7)
Testing
Gaps
print(["Mia"])
Check Answer
Spots
1scores = (85, 92, 78)
2scores.append(90)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Bear' badge — Forest Guardian, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

▶ Run these on the board — two answers, the class points left or right, you reveal why. No devices.

1. You need to store the scores of 30 students in the order they were entered. Which structure fits best?
A. A list: scores = [72, 85, 90] ✓
B. A tuple of student names stored as keys
A list is an ordered collection that can grow or change, which suits a series of scores.
2. You want to look up a student's phone number using their name. Which structure fits best?
A. A dictionary: phones = {"Mia": "0412"} ✓
B. A list: phones = ["Mia", "0412"]
A dictionary lets you look up a value by its key, so phones["Mia"] gives the number straight away.
3. Which is the best choice to store the fixed latitude and longitude of Melbourne, which should never change?
A. A list: location = [-37.81, 144.96]
B. A tuple: location = (-37.81, 144.96) ✓
A tuple is a fixed group of values that cannot be changed after it is created, which suits coordinates.
4. True or false: A tuple is a good choice for a shopping list that you keep adding items to.
A. False: use a list, because tuples cannot be changed ✓
B. True: tuples are the best for growing collections
Tuples are fixed, so there is no append(). A list is better when items are added or removed.
5. You are storing 3 students, each with a name, a year level and a house. Which structure is best for the whole collection?
A. A single tuple holding every name, year and house mixed together
B. A list of dictionaries, one dictionary per student ✓
A list of dictionaries stores records: the list keeps the order of students and each dictionary labels the fields with keys.

Match the Pairs

scores = [85, 92, 78] → A list: an ordered collection of values that you can loop through and change
ages = {"Mia": 15, "Leo": 14} → A dictionary: look up a value quickly using its key
A tuple is best for a fixed group of values that should not change, like a map point → point = (10, 25)
A list of dictionaries is best for storing records, where each dictionary holds one item's details → students = [{"name": "Mia", "year": 9}]
colours = ("red", "blue") colours.append("green") → A tuple cannot be changed, so append() causes an error. Use a list if the values need to grow.
phone = ["Mia", "0412 345 678"] print(phone["Mia"]) → A list is indexed by position, not by name. To look up by a key, use a dictionary instead.

Key Term

list, dict, tuple
Pick the structure by how you use the data: a list for an ordered collection, a dict for lookup by key, and a tuple for a fixed group of values that should not change.

Fill in the Blanks

1. ages = {"Mia": 15, "Leo": 16} print(ages["Mia"])
Hint: Type the name of the variable holding the data you look up by key.
2. rgb = tuple([255, 128, 0])
Hint: Type the function that makes a fixed group of values that cannot change.
3. kids = [{"age": 9}, {"age": 12}] print(kids[0]["age"])
Hint: Type the index of the first record in the list of dictionaries.
4. stock = {"apple": 4, "pear": 7} print(stock.get("pear"))
Hint: Type the dictionary method that looks up a value using its key.
5. names = ["Zoe", "Sam", "Ali"] for name in names: print(name)
Hint: Type the variable for the ordered collection to loop through.

Spot the Error

Question 1
A scores = (85, 92, 78)
B scores.append(90)
C print(scores[0])
Line A — Scores is an ordered collection that grows, so it needs a list. A tuple is fixed and has no append(), so line 2 would fail. It should be scores = [85, 92, 78].
Question 2
A ages = {"Mia": 15, "Leo": 16}
B print(ages[0])
C print(len(ages))
Line B — A dictionary is looked up by key, not by position number. There is no key 0, so this causes a KeyError. It should be print(ages["Mia"]).
Question 3
A RGB = (255, 128, 0)
B RGB[0] = 200
C print(red)
Line B — A tuple holds a fixed group of values and cannot be changed after it is created. Assigning to RGB[0] causes a TypeError. The line should read the value: red = RGB[0].
Question 4
A student = ["name": "Ava"]
B student["year"] = 10
C print(student["name"])
Line A — Key: value pairs belong in a dictionary, which uses curly brackets. Square brackets make a list, which cannot hold key: value pairs. It should be student = {"name": "Ava"}.
Question 5
A dog = {"name": "Rex"}
B cat = {"name", "Kit"}
C pets = [dog, cat]
D print(pets[1]["name"])
Line B — A dictionary needs a colon between the key and the value. A comma makes a set of two strings instead of a record. It should be cat = {"name": "Kit"}.

Student with a class code? Join your class →

Classroom tools: Hangman · Bingo · Heads or Tails · Higher or Lower · Name Picker · Team Generator · Seating Plan