What does the add() method do in a set?
Adds a single element to the set.
True or false: The remove() method raises an error if the element is not found.
TRUE
Use discard() to avoid errors when removing elements.
What is the purpose of the clear() method?
Removes all elements from the set.
Fill in the blank: update() merges another set or iterable into the set, adding _______.
elements
What does the discard() method do?
Removes an element from the set without raising an error.
Define pop() in the context of sets.
Removes and returns an arbitrary element from the set.
What does the intersection() method return?
A new set containing elements common to both sets.
True or false: union() creates a set with unique elements from both sets.
TRUE
What is the function of the difference() method?
Returns a set of elements in one set but not in another.
Fill in the blank: symmetric_difference() returns elements that are in either set, but not _______.
both
What does the issubset() method check?
Determines if one set is a subset of another.
What is the purpose of the issuperset() method?
Checks if one set contains all elements of another set.
True or false: Sets can contain duplicate elements.
FALSE
Sets automatically remove duplicates.
What does the copy() method do?
Creates a shallow copy of the set.
Fill in the blank: The frozenset() function creates an immutable _______.
set
What is the output of len() on a set?
Returns the number of unique elements in the set.
Define set comprehension.
A concise way to create sets using an expression and a loop.
What does the difference_update() method do?
Removes elements found in another set from the current set.
True or false: Sets are ordered collections.
FALSE
Sets do not maintain any order of elements.
What does the pop() method return if the set is empty?
Raises a KeyError.
Fill in the blank: The intersection_update() method modifies the set to keep only _______.
common elements
What is the result of set1 | set2?
The union of set1 and set2.
What does set1 & set2 represent?
The intersection of set1 and set2.
Define set difference.
The elements in one set that are not in another set.