IT 117: Intermediate Scripting
Answers to Class 9 Ungraded Quiz


  1. Write a for loop that prints the elements in set s1.
    for element in s1:
        print(element)
  2. Write a Python expression to see if the set s1 contains 5.
    5 in s1
  3. Write a Python expression to see if the set s1 does not contain 12.
    12 not in s1
  4. Write a Python expression that returns the union of the sets A and B.
    A.union(B) or B.union(A)
  5. Write a Python expression that returns the intersection of the sets A and B.
    A.intersection(B) or B.intersection(A)
  6. Write a Python expression that returns the difference between the sets A and B.
    A.difference(B) or A - B
  7. Is the difference between the sets A and B the same as the difference between the sets B and A
    no
  8. What does the clear method do?
    removes all elements from a set
  9. Write a Python expression that returns the largest element in the set A.
    max(A)
  10. Write a Python expression that returns the smallest element in the set A.
    min(A)