Nuttige ingebouwde functies voor sets Flashcards
my_set.add(1)
adding the number 1 to the set
my_set.clear()
remove all the elements from a set
my_set.copy()
copies the old set, doesn’t update it
set1.difference(set2)
you compare set a with b and say which are not in the
other one
set1.difference_update(set2)
removes the items that exist in both sets from set1
set1.discard(2)
removes the element from the set
set1.intersection(set2)
gives the numbers the sets have the same, where
they overlap
set1.intersection_update(set2)
removes items that is not
present in both sets
set1.isdisjoint(set2)
checks whether the two sets are disjoint or not
(nothing in common)
set1.issubset(set2)
true if all elements of a set are present in
another set
set1.issuperset(set2)
true if all elements of a set are in another set
set1.pop()
remove and return a set element. Removes first
my_set.remove(4)
remove an element from a set
set1.symmetric_difference_update(set2)
makes set a consist of only the
differences
set1.symmetric_difference(set2)
gives the difference between the two sets