Nuttige ingebouwde functies voor sets Flashcards

1
Q

my_set.add(1)

A

adding the number 1 to the set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

my_set.clear()

A

remove all the elements from a set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

my_set.copy()

A

copies the old set, doesn’t update it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

set1.difference(set2)

A

you compare set a with b and say which are not in the
other one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

set1.difference_update(set2)

A

removes the items that exist in both sets from set1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

set1.discard(2)

A

removes the element from the set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

set1.intersection(set2)

A

gives the numbers the sets have the same, where
they overlap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

set1.intersection_update(set2)

A

removes items that is not
present in both sets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

set1.isdisjoint(set2)

A

checks whether the two sets are disjoint or not
(nothing in common)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

set1.issubset(set2)

A

true if all elements of a set are present in
another set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

set1.issuperset(set2)

A

true if all elements of a set are in another set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

set1.pop()

A

remove and return a set element. Removes first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

my_set.remove(4)

A

remove an element from a set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

set1.symmetric_difference_update(set2)

A

makes set a consist of only the
differences

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

set1.symmetric_difference(set2)

A

gives the difference between the two sets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

set3 = set1.union(set2)

A

unites the two sets and removes dubbles and
ordered

15
Q

set1.update(set2)

A

add the elements of set 2 to set 1