Topics / Dictionaries

Dictionaries

Key–value lookup and updating associated data.

Models frequently confuse membership of keys with membership of values. That is an evaluation opportunity, not a reason to skip the concept.

Identify Terminology L1 Knowledge Atoms ~1 min

Keys and values

In this dictionary, what is "apples" called?

Start activity
Define a Concept L1 Knowledge Atoms ~2 min

Define a dictionary

In your own words, what is a dictionary in Python, and how is it different from a list?

Start activity
Match Terms to Definitions L1 Knowledge Atoms ~2 min

Match the dictionary vocabulary

Match each term to the definition that fits it. The code is there so you can see what each term refers to; …

Start activity
Program Purpose L2 Comprehension Macro Structure ~3 min

What is this dictionary program for?

What overall problem is this program solving? Avoid describing only the syntax.

Start activity
Explain Code L2 Comprehension Blocks ~3 min

What does this dictionary update do?

Explain in plain English what this code does. Say what the dictionary holds, what the second line changes, and what is printed.

Start activity
Complete the Code L3 Application Blocks ~2 min

Print every key with its value

The program should print each item with its price, as 'tea 2' and then 'cake 4'. Which expression completes the blank?

Start activity
Compare Solutions L4 Analysis Relations ~4 min

Two vote counters

Two AI-generated programs both try to tally votes into a dictionary. Each is a separate program. Compare them. Which statement is true?

Start activity
Code Improvement L5 Synthesis Macro Structure ~5 min

Tighten this generated lookup

An AI produced the function below for: return the stock count for a product name, or 0 if the product is missing. …

Start activity
AI Suggestion Evaluation L6 Evaluation Macro Structure ~4 min

Is this stock total correct?

Requirement: total_stock(stock) returns the total number of items in stock, where stock maps product names to counts (for example {'apples': 5, 'pears': …

Start activity