Learning outcomes
- Store and organize collections of data
Core concepts
Lessons
Module goal
Learner moves beyond single values and understands how to store, organize and access collections of data — the foundation for almost every real program that follows.
Lesson 1 of 6 · lecture
Why we need data structures
Step 1 of 2
Every variable so far held exactly one piece of information. Real programs rarely deal with one thing — a repair shop tracks dozens of devices, a contact book holds hundreds of contacts. Naming each one separately (device1, device2, device3…) would be unmanageable.
Data structures let you store collections of related data under a single name, with organised ways to access, change and work with the collection as a whole.
Teaching point
This isn't a new topic bolted on — variables, loops and functions all become dramatically more useful once they work with structured collections instead of single values.
Guided labs
Lab part 1 — contact book using a dictionary
- 1.Create data_structures.py
- 2.Build a dictionary representing one contact (name, phone, email)
- 3.Print each value individually using its key
- 4.Update one value and print the dictionary again
contact = {
"name": "Kenneth",
"phone": "0244000000",
"email": "kenneth@nextdoortech.com"
}
print(f"Name: {contact['name']}")
print(f"Phone: {contact['phone']}")
print(f"Email: {contact['email']}")
contact["phone"] = "0201111111"
print("Updated contact:", contact)Lab part 2 — to-do list using a list
- 1.Create an empty list called tasks
- 2.Use .append() to add three repair tasks
- 3.Use a for loop to print each task with its position number
- 4.Remove one task with .remove() and print the updated list
tasks = []
tasks.append("Replace iPhone screen")
tasks.append("Fix Samsung charging port")
tasks.append("Diagnose Pixel battery issue")
for index, task in enumerate(tasks):
print(f"{index + 1}. {task}")
tasks.remove("Fix Samsung charging port")
print("Updated task list:", tasks)Teaching point
enumerate() gives both the position and the item in a loop. index + 1 is used so the user sees a natural 1-based count instead of Python's 0-based index.
Success criteria
Both scripts run without errors, and the learner can explain why a dictionary suited the contact (lookup by name) and a list suited the tasks (ordered collection you add to and remove from).
Knowledge Check
Question 1 of 6
What is the index of the first item in a Python list?
What you read
- When to use a list vs. a dictionary vs. a set
- How indexing works
- Mutability differences
What you understand
Key takeaways
- — Real programs manage collections of data, not single values
Hands-on lab
Lab tasks
- 1.Build a simple contact book using a dictionary
- 2.Manipulate a to-do list using a list
Knowledge check
- Choose the right data structure for a scenario
Write your answers in your own notes before moving on — explaining a concept in your own words is the fastest way to find the gaps.