Set Examples Flashcards

1
Q

thisset = {“apple”, “banana”, “cherry”}

thisset.add(“orange”)

print(thisset)

A

{‘banana’, ‘apple’, ‘cherry’, ‘orange’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.difference(y)

print(z)

A

{‘cherry’, ‘banana’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

x.difference_update(y)

print(x)

A

{‘cherry’, ‘banana’}

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

thisset = {“apple”, “banana”, “cherry”}

thisset.discard(“banana”)

print(thisset)

A

{‘cherry’, ‘apple’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.intersection(y)

print(z)

A

{‘apple’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
x = {"a", "b", "c"}
y = {"c", "d", "e"}
z = {"f", "g", "c"}

result = x.intersection(y, z)

print(result)

A

{‘c’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

x.intersection_update(y)

print(x)

A

{‘apple’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "facebook"}

z = x.isdisjoint(y)

print(z)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.isdisjoint(y)

print(z)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
x = {"a", "b", "c"}
y = {"f", "e", "d", "c", "b"}

z = x.issubset(y)

print(z)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
x = {"f", "e", "d", "c", "b", "a"}
y = {"a", "b", "c"}

z = x.issuperset(y)

print(z)

A

True

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

fruits = {“apple”, “banana”, “cherry”}

fruits.pop()

print(fruits)

A

{‘banana’, ‘cherry’}

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

fruits = {“apple”, “banana”, “cherry”}

fruits.remove(“banana”)

print(fruits)

A

{‘apple’, ‘cherry’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.symmetric_difference(y)

print(z)

A

{‘google’, ‘microsoft’, ‘banana’, ‘cherry’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

x.symmetric_difference_update(y)

print(x)

A

{‘google’, ‘microsoft’, ‘banana’, ‘cherry’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.union(y)

print(z)

A

{‘microsoft’, ‘banana’, ‘google’, ‘cherry’, ‘apple’}

17
Q
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

x.update(y)

print(x)

A

{‘cherry’, ‘apple’, ‘banana’, ‘google’, ‘microsoft’}