Python sets and tuples

A set stores distinct hashable elements and supports union, intersection, and difference. Set iteration order is not a sorted-order contract, so sorted is used for display.

Python
first = {1, 2, 3}
second = {3, 4}
print(sorted(first & second))
print(sorted(first | second))
point = (2, 5)
x, y = point
print(x + y)
assert len({1, 1, 2}) == 2
Read the full lesson