1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
set.clear()
removes all elements from the set, leaving it empty.
set.pop()
removes and returns an arbitrary element from the set.
set.add(item)
inserts a single element into the set.
set.remove(old)
deletes a specific element from the set, raising a KeyError if it's not present.
set.discard()
(same as set.remove()) — deletes a specific element from the set, but does nothing (no error) if it's not present.
set.update(new)
adds all elements from another iterable into the set, in place. (filters out duplicates)
set.intersection_update(new)
keeps only the elements also found in new set in place.
set.difference_update(new)
removes all elements found in another set, in place.
set.symmetric_difference_update(new)
keeps only elements in exactly one of the two sets, in place.
set.copy()
returns a shallow copy of the set.
set.union(new)
returns a new set containing all elements from both sets.
set.intersection(new)
returns a new set of elements common to both sets.
set.symmetric_difference(new)
creates and returns a new set containing all elements that are in either the original set or the new iterable, but not in both.
set.issubset(other)
checks whether every element of the set is also in other
len(set)
returns the number of elements in the set.
max(set)
returns the largest element in the set.
min(set)
returns the smallest element in the set.
sum(set)
returns the sum of all elements in the set (numeric elements only).
any(set)
returns True if at least one element is truthy.
all(set)
returns True if every element is truthy.
sorted(set)
returns a new sorted list of the set's elements.
set.difference(new)
returns a new set of elements in the first set but not the second