Chapter 6: Dictionaries and Sets 7
d. Sets are unordered, so there’s no significance to the iteration order.
6.3 Q4: Consider the following session:
In [1]: numbers = list(range(10)) + list(range(5))
In [2]: numbers
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]
In [3]: set(numbers)
Out[3]: ???
Which of the following would be displayed where we wrote ??? in Out[3]?
a. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
b. (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
c. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
d. {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
6.3 Q5: Which of the following statements a), b) or c) is false?
a. Sets are immutable, so sets can have other sets as elements.
b. A frozenset is an immutable set—it cannot be modified after you create it, so a
set can contain frozensets as elements.
c. The built-in function frozenset creates a frozenset from any iterable.
d. All of the above statements are true.
6.3.1 Comparing Sets
6.3 Q6: Which of the following statements is false?
a. The <= operator tests whether the set to its left is an improper subset of the one
to its right—that is, all the elements in the left operand are in the right operand,
and the sets might be equal.
b. You also can check for an improper subset with the set method issubset.
c. You can check for an improper superset with the set method issuperset.
d. The argument to issubset or issuperset must be a set.