Assessment Questions: Python Sets

Nov 6, 2013 • Sean Dawson

What is the value of mystery after this statement?
<br /> mystery = set([1, 2, 3]).intersection(set([3, 2, int("1")]))<br />

  1. set([2])
  2. set([1, 1, 2, 3])
  3. set([1, 2, 3])
  4. set([2, 3])

Which of the following objects can be added to a set?

  1. set([1,2,3])
  2. frozenset([1,2,3])
  3. list([1,2,3])
  4. None of the above — sets cannot contain collections as elements