IT 117: Intermediate to Scripting
Answers to Class 8 Ungraded Quiz

  1. Can a value appear more than once in a set?
    no
  2. What does it mean for a set B to be a subset of set A?
    all the values in B are contained in 
  3. What is the union of the sets A and B?
    a new set consisting of all the elements in A and all the elements in B
  4. If we have the sets A and B with the elements below, what are the elements formed by the union of A and B?
    A = {1, 2, 3}
    B = {3, 4, 5}
    {1, 2, 3, 4, 5}
  5. If we have the sets A and B with the elements below, what are the elements formed by the intersection of A and B?
    A = {1, 2, 3}
    B = {3, 4, 5}
    {3}
  6. Write the Python statement to create an empty set named s1.
    s1 = set()
  7. Write a Python statement to create the set s2 containing the values 1, 2 and 3, using a set literal.
    s2 = {1, 2, 3}
  8. If the variable s1 pointed to an empty set, what would you see if you printed this variable?
    set()
  9. Name the two set methods that can be used to add elements to a set.
    add() and update()
  10. Name the two set methods that can be used to remove an element from a set.
    discard() and remove()