More About Sets¶
Sets¶
Unordered collection of distinct objects
⟶ set in a mathematical sense
Membership tests
Addition and removal of elements
Mathematical operations, like …
Intersection
Union
Difference
Operations on Sets (1)¶
Test operations
|
Is |
|
|
|
|
|
… |
|
Does |
|
Is |
|
Is |
|
Is |
|
Is |
Operations on Sets (2)¶
Building sets from other sets
|
Union |
|
Intersection |
|
Difference |
|
Symmetric difference |
All operations available as |=
(for example)
>>> s = {1, 2, 3}
>>> s = set([1, 2, 3]) # ... or any iterable