Lesson 3 of 10

Dictionaries & Records 📚

🎯 Grades 6–8 ⏱ ~25 minutes 💚 Intermediate

What You'll Learn

  • Create dictionaries with key-value pairs
  • Access and update values using keys
  • Loop through dictionaries with .items()
  • Build a list of dictionaries to represent a table

🎉 Check Your Understanding

1. How do you access the "name" value in student = {"name": "Alex"}?

student[0]
student["name"]
student.name
student(name)

2. What method lets you loop through every key-value pair in a dictionary?

.keys()
.values()
.items()
.pairs()

3. What happens when you assign to a key that already exists in a dictionary?

Python raises an error
A second entry is added
The existing value is updated
The key is deleted

4. A list of dictionaries is useful because it acts like a ___.

Single variable
Data table with rows and columns
Python function
File on disk