Recall & Review
beginner
What is the union of two sets in Python?
The union of two sets is a new set containing all unique elements from both sets. It combines elements without duplicates.
Click to reveal answer
beginner
What does the intersection of two sets represent?
The intersection of two sets is a new set containing only the elements that appear in both sets.
Click to reveal answer
beginner
How do you find the union of sets
a and b in Python?You can use
a.union(b) or the | operator like a | b.Click to reveal answer
beginner
How do you find the intersection of sets
a and b in Python?You can use
a.intersection(b) or the & operator like a & b.Click to reveal answer
beginner
If
a = {1, 2, 3} and b = {3, 4, 5}, what is a | b and a & b?a | b is {1, 2, 3, 4, 5} (union), and a & b is {3} (intersection).Click to reveal answer
Which operator gives the union of two sets
a and b in Python?✗ Incorrect
The
| operator returns the union of two sets.What does
a & b return when a and b are sets?✗ Incorrect
The
& operator returns the intersection of two sets.Which method can be used to find the union of two sets
a and b?✗ Incorrect
The
union() method returns the union of two sets.If
a = {1, 2} and b = {2, 3}, what is a & b?✗ Incorrect
The intersection contains only elements common to both sets, which is {2}.
What will
a | b return if a = {5, 6} and b = {6, 7}?✗ Incorrect
The union combines all unique elements from both sets.
Explain in your own words what the union and intersection of two sets mean.
Think about combining two groups of friends versus finding friends you both have.
You got /2 concepts.
Describe how to find the union and intersection of two sets in Python using operators and methods.
Remember the symbols look like OR and AND.
You got /4 concepts.