Module 21: Dictionary Practice

Manipulate data structures like a pro. Let's master Python dictionaries!

Dictionary Anatomy

Dictionaries store key-value pairs. Click on the different parts of the dictionary below to identify them.

{"name": "Atlas", "version": 2.1, "status": "active"}

Identify all parts!

Key Finder Challenge

Use the `in` keyword (conceptually) to check for keys. Select the keys that EXIST in the `config` dictionary below.

config = { "mode": "auto", "retries": 3, "user": "admin" }

Which of these keys are in `config`?

Iterate & Identify Output

Dictionaries offer different ways to loop through their contents. Select the correct output for the given iteration method.

student_scores = { "Alice": 85, "Bob": 92, "Charlie": 78 }

Dictionary Deletion

The `del` keyword removes items from a dictionary by key. Click on the item you want to remove from the `inventory` below. Task: Delete the "pencil" entry.

Dictionary Mini Missions!

Combine your knowledge. Complete these dictionary tasks using the simulator.

Mission 1: Create a Profile

Create a dictionary named `user_profile` with two keys: `"username"` (value: `"AI_Learner"`) and `"level"` (value: 5).

Mission 2: Print Stock Counts

Given `stock = {"apples": 50, "bananas": 120}`, write code to iterate and print only the values (the counts) each on a new line.

Mission 3: Check & Update Settings

Given `settings = {"dark_mode": True, "notifications": True}`, check if `"notifications"` exists. If it does, print `"Notifications active"`. Then, delete the `"dark_mode"` key.

Module 21 Practice Complete!

Excellent work navigating dictionaries! You're building strong data manipulation skills.
Ready for a deeper dive? Try the Advanced Practice for Module 21!