Recall & Review
beginner
What does it mean if set A is a subset of set B?
Set A is a subset of set B if every element in A is also in B.
Click to reveal answer
beginner
How do you check if set A is a superset of set B in Python?
Use the method
A.issuperset(B) or the operator A >= B.Click to reveal answer
intermediate
What is the difference between
issubset() and issuperset()?issubset() checks if all elements of one set are in another set (smaller or equal), while issuperset() checks if one set contains all elements of another set (larger or equal).Click to reveal answer
beginner
What will
{1, 2} <= {1, 2, 3} return in Python?It returns
True because {1, 2} is a subset of {1, 2, 3}.Click to reveal answer
beginner
Can a set be a subset and superset of itself?
Yes, a set is always a subset and superset of itself because all elements match exactly.
Click to reveal answer
Which Python operator checks if set A is a subset of set B?
✗ Incorrect
The operator <= checks if all elements of A are in B, meaning A is a subset of B.
What does
A.issuperset(B) return if A contains all elements of B?✗ Incorrect
issuperset returns True if A contains every element of B.
If
A = {1, 2, 3} and B = {2, 3}, which is true?✗ Incorrect
A contains all elements of B, so A is a superset of B.
What will
{1, 2, 3} >= {1, 2, 3} return?✗ Incorrect
A set is always a superset of itself, so it returns True.
Which method checks if a set is a subset of another?
✗ Incorrect
issubset() checks if all elements of one set are in another.
Explain how to check if one set is a subset or superset of another in Python.
Think about methods and operators that compare sets.
You got /4 concepts.
Describe a real-life example where subset and superset checks might be useful.
Imagine comparing guest lists or permissions.
You got /4 concepts.