1A = {1, 2, 3, 4, 5}2B = {4, 5, 6, 7}3A | B4A & B5A - B6A ^ BABU12436587
Zone tiles: only in A, in A and B, only in B; the board around them is UOrange wash: the zones that make up the current answerResult row and answer block: the set or value the operation givesPython card: the operator that does each operationTwo sets drawn as a Venn diagram on the universe board: A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7} overlap over 4 and 5; 8 is in U but in neither set. Number tokens hop from each line of Python into the board, then from the board into the result row; the zones that make up each answer are washed in orange: all three for A ∪ B, the middle for A ∩ B, the left for A − B, both sides for A △ B. The empty set, written ∅, has no elements. In Python it is set(); {} on its own makes an empty dict, not a set.

What a set is

  1. A set is a collection of different things, called its elements. We write a set in curly braces: A = {1, 2, 3, 4, 5}. Order does not matter, and each element is simply in the set or not.

Combining sets

Size and subsets

Try it in the Python prompt

;; step 1/10 · A set of elements
>>> A = {1, 2, 3, 4, 5}
>>> A
{1, 2, 3, 4, 5}
>>> {5, 4, 3, 2, 1} == A      # order does not matter
True
>>> {1, 1, 2} == {1, 2}        # nor does repeating
True

Building a set throws duplicates away: set([1, 2, 2, 3]) gives {1, 2, 3}. A set has no order either, so {1, 2} == {2, 1} is True. Symbols and Python: ∈ is in, ∪ is |, ∩ is &, − is -, △ is ^ and ⊆ is <=.