← Python

Dictionaries – Basics (creation, accessing)

A dictionary maps unique keys to values using key: value pairs inside curly braces

What it does: A dictionary stores data as key-value pairs inside curly braces: person = {'name': 'Alice'}. The key is the label used to look something up, and the value is the data stored under it. A value is accessed with square brackets around its key — person['name'] — which looks items up by name rather than by position, unlike a list.

Common mistakes: Using square brackets to create a dictionary — person = ['name': 'Alice'] — is a syntax error; dictionaries need curly braces {}. Looking up a key that doesn't exist raises a KeyError rather than returning nothing.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What is a dictionary?
A collection of key-value pairsAn ordered list of items
Matches
❌ person = {'name': 'Ali'} print(person['age'])
Error: Key 'age' doesn't exist
Applying
Meanings
Term
Dictionary
Meaning
A collection of key-value pairs in curly braces {}.
Practice
person = {'name': 'Alice', 'age': 15}
Testing
Gaps
person = 'name': 'Alice'
Check Answer
Spots
1# Create a person dictionary
2person = ['name': 'Alice']

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Sand Cat' badge — Precision Prowler, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What is a dictionary?
A. A collection of key-value pairs ✓
B. An ordered list of items
Dicts store data as pairs — each key maps to a value, like a lookup table
2. How do you create a dictionary?
A. Square brackets []
B. Curly braces {} ✓
Square brackets [] make lists; curly braces {} make dicts (or sets)
3. d = {'a': 1}\nprint(d['a'])\nWhat prints?
A. 1 ✓
B. 'a'
d['a'] looks up the key 'a' and returns its value, which is 1
4. What separates a key from its value?
A. An equals sign =
B. A colon : ✓
Syntax is key: value — e.g. {'name': 'Alice'}
5. Can dictionary keys be duplicated?
A. No each key must be unique ✓
B. Yes
If you assign the same key twice, the second value overwrites the first

Match the Pairs

person = {'name': 'Ali'} print(person['age']) Error: Key 'age' doesn't exist
d = {name: 'Alice'} Error: Keys need quotes if string
person = {'name': 'Ali', 'age': 20} Valid: Dict with two key-value pairs
d = {} d['x'] = 10 Ok: Add key to empty dict
p = {'name':'Ali'} print(p['name']) Output: Ali
p = {} print(type(p)) Output: <class 'dict'>

Key Term

Dictionary
A collection of key-value pairs in curly braces {}.~~Key

Fill in the Blanks

1. person = {'name': 'Alice'}
2. print(person['name'])
3. d = {} d['color'] = 'blue'
4. pet = {'type': 'cat'}
5. scores = {'math': 90, 'english': 85}

Spot the Error

Question 1
A # Create a person dictionary
B person = ['name': 'Alice']
C print('Name:', person['name'])
D print('Done')
Line B — Dictionaries use curly braces {}, not square brackets []
Question 2
A # Create a person dictionary
B person = {'name' = 'Alice'}
C print('Name:', person['name'])
D print('Done')
Line B — Use colon : between key and value, not equals =
Question 3
A person = {'name': 'Alice'}
B greeting = person[name]
C print('Hello,', greeting)
D print('Done')
Line B — Key must be in quotes: 'name' is a string, not a variable
Question 4
A person = {'name': 'Alice'}
B greeting = person('name')
C print('Hello,', greeting)
D print('Done')
Line B — Use square brackets [] to access keys, not parentheses ()
Question 5
A person = {'name': 'Alice'}
B label = 'Greeting'
C greeting = person.name
D print('Hello,', greeting)
Line C — Use bracket notation person['name'], not dot notation person.name
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?