Sets – Operations
Sets support mathematical operations: union |, intersection &, difference -, and subset tests
Understanding Sets – Operations in Python
What it does: people[0] gets the first dict, then ['name'] gets its name value. d['nums'] returns the list, then .append() adds to it. Think of it as a table — each dict is a row with named columns. Lists hold multiple records; dicts give each record named fields. .add() is for sets; lists use .append() to add items. Dict values can be any Python object — strings, numbers, lists, even other dicts. d['tags'] is the list ['python', 'code'] — len() of that list is 2. The value is a list, so use an integer index: d['tags'][0], not d['tags']['a'].
Common mistakes: people is a list: must index first: people[0]['name']. Dicts use keys not indices. Use ['name'] not [0].
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 41–50) and word search (Modules 41–63).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
List of dictsFill in the Blanks
Spot the Error
Student with a class code? Join your class →