Warmup

Create a dictionary and use the .get() dictionary method to safely access the value of a key in the dictionary. Include a default value in your method call.

.get() info

Agenda

  • Quick Review
  • Unit 3 Quiz 2
  • Assignment 3.10 Mixed Practice

Lesson 3.10 – Mixed Practice: Lists, Tuples, and Dictionaries

What we’ll learn today

  • How lists, tuples, and dictionaries can be used together
  • Practice solving small problems that combine them
  • Strengthen fluency with data structures

Quick Review

  • Which data structure is immutable?
  • Which data structure uses key–value pairs?

Combining Lists and Tuples

  • Tuples can store related pieces of info in a list
students = [("Alice", 16), ("Bob", 17), ("Cathy", 15)]
for name, age in students:
    print(name, "is", age)

Combining Lists and Dictionaries

  • A list of dictionaries is common
books = [
    {"title": "1984", "author": "Orwell"},
    {"title": "Dune", "author": "Herbert"}
]
for book in books:
    print(book["title"], "by", book["author"])

Mini Practice

  • Make a list of 3 pets as tuples: (type, name)
  • Loop through and print them

Dictionaries of Lists

classroom = {
    "students": ["Alice", "Bob", "Cathy"],
    "grades": [90, 85, 92]
}
print(classroom["students"])

Class Question

  • When would you want a list of dictionaries vs. a dictionary of lists?

Mini Challenge

Write a program that:

  1. Creates a list of dictionaries, each with keys: name and score
  2. Loops through to print each name and score
  3. Finds and prints the highest score