← Python

Lists + Dictionaries

A list of dictionaries represents a table of records where each dict is one row

What it does: & gives items that appear in both sets. 2 and 3 are in both a and b. - is difference — items in the left set but not the right. ^ is symmetric difference — items in either set but not both. Think of | as 'OR' — items in set A OR set B (or both). Think of & as 'AND' — items in set A AND set B. issubset checks if every item in the first set exists in the second. union() and | both combine all items — intersection() and & find common items. | & - ^ all return new sets; use |= &= etc. to modify in place.

Common mistakes: Sets don't support + for union. Use | or .union(). Use & for set intersection, not 'and' (which is a boolean operator).

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
{1,2,3} | {3,4,5} returns?
{1, 2, 3, 4, 5}{3}
Matches
❌ a = {1,2} b = [3,4] a | b
Error: Both must be sets for |
Applying
Meanings
Term
Union
Meaning
Combines all items from both sets with no duplicates.
Practice
a = {1, 2, 3}
Testing
Gaps
print(a b)
Check Answer
Spots
2b = {3, 4}
3print(a + b)

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

The 'Red Panda' badge — Forest Explorer, 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. {1,2,3} | {3,4,5} returns?
A. {1, 2, 3, 4, 5} ✓
B. {3}
| is union — all items from both sets, duplicates removed
2. {1,2,3} & {2,3,4} returns?
A. {1, 2, 3, 4}
B. {2, 3} ✓
& is intersection — only items that appear in both sets
3. {1,2,3} - {2,3,4} returns?
A. {1} ✓
B. {4}
- is difference — items in the left set but not the right
4. {1,2,3} ^ {2,3,4} returns?
A. {2, 3}
B. {1, 4} ✓
^ is symmetric difference — items in either set but not both
5. What does | do with sets?
A. Union combines all items ✓
B. Intersection
Think of | as 'OR' — items in set A OR set B (or both)

Match the Pairs

a = {1,2} b = [3,4] a | b Error: Both must be sets for |
s = {1,2,3} s.add([4,5]) Error: Lists can't be set elements
a = {1,2,3} b = {2,3,4} a & b Valid: Intersection {2, 3}
a = {1,2,3} b = {2,3,4} a - b Ok: Difference {1}
a={1,2} b={2,3} print(a | b) Output: {1, 2, 3}
a={1,2} b={2,3} print(a & b) Output: {2}

Key Term

Union
Combines all items from both sets with no duplicates.~~Intersection

Fill in the Blanks

1. a = {1, 2, 3} b = {3, 4} print(a | b)
2. a = {1, 2, 3} b = {2, 3, 4} print(a & b)
3. a = {1, 2, 3} b = {2, 3} print(a - b)
4. a = {1, 2} b = {1, 2, 3} print(a.issubset(b))
5. a = {1, 2, 3} b = {2, 3, 4} print(a ^ b)

Spot the Error

Question 1
A a = {1, 2, 3}
B b = {3, 4}
C print(a + b)
Line C — Sets don't support + for union. Use | or .union().
Question 2
A a = {1, 2, 3}
B b = {2, 3, 4}
C print(a and b)
Line C — Use & for set intersection, not 'and' (which is a boolean operator)
Question 3
A a = {1, 2, 3}
B b = {2, 3, 4}
C print(a or b)
Line C — Use | for set union, not 'or' (which is a boolean operator)
Question 4
A a = {1, 2, 3}
B b = {3, 4}
C combined = a.union[b]
D print('Union:', combined)
Line C — Use parentheses () to call methods, not square brackets []
Question 5
A print({1, 2}.subset({1, 2, 3}))
B a = {1, 2}
C b = {1, 2, 3}
D print('Done')
Line A — The method is issubset(), not subset()
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?