← Python Coding Track

Module 05BeginnerWeeks 3–4

Data Structures

01

Learning outcomes

  • Store and organize collections of data
02

Core concepts

ListsTuplesDictionariesSetsIndexing and slicing
03

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.

04

Guided labs

Lab part 1 — contact book using a dictionary

  1. 1.Create data_structures.py
  2. 2.Build a dictionary representing one contact (name, phone, email)
  3. 3.Print each value individually using its key
  4. 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. 1.Create an empty list called tasks
  2. 2.Use .append() to add three repair tasks
  3. 3.Use a for loop to print each task with its position number
  4. 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).

05

Knowledge Check

Question 1 of 6

What is the index of the first item in a Python list?

06

What you read

  • When to use a list vs. a dictionary vs. a set
  • How indexing works
  • Mutability differences
07

What you understand

Key takeaways

  • Real programs manage collections of data, not single values
08

Hands-on lab

Lab tasks

  1. 1.Build a simple contact book using a dictionary
  2. 2.Manipulate a to-do list using a list
09

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.

10

Mark progress