Professional Documents
Culture Documents
4.5. Sets - Python Notes (0.14.0)
4.5. Sets - Python Notes (0.14.0)
0)
4.5. Sets
SEARCH
Contents
Sets Go
Quick example Enter search terms
Ordering or a module, class or
Operators function name.
8. Notes about
4.5.2. Ordering
sorting lists and
Just as with dictionaries, the ordering of set elements is dictionaries
quite arbitrary, and shouldn’t be relied on.
9. Notes about
booleans and
4.5.3. Operators logical operators
https://thomas-cokelaer.info/tutorials/python/sets.html 1/2
2021/5/13 4.5. Sets — Python Notes (0.14.0)
>>> a.intersection(b)
set([2, 3])
>>> c.issubset(a)
True
>>> c <= a
True
SEARCH
>>> c.issuperset(a)
False
>>> c >= a Go
False Enter search terms
or a module, class or
>>> a.difference(b)
function name.
set([1])
>>> a - b This page: Show
set([1])
source.
1. Iterators
2. Generators
3. Exceptions
4. Decorators
5. Classes
6. Namespace and
scoping rules
7. Packaging
8. Notes about
sorting lists and
dictionaries
9. Notes about
booleans and
logical operators
10. Notes on
https://thomas-cokelaer.info/tutorials/python/sets.html 2/2