Set Operations
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Below is a Python program, split up into several pieces. After each
program, submit the value that would be associated with the variable answer
. Note: the checker accepts valid python objects so if the answer is a string it must be wrapped in quotation marks.
If the program in question would cause an error, write error (no quotes!) in the box.
a = {1, 2, 3, 4, 4, 4}
a.add(5)
answer = len(a)
a = {}
a.add("hello")
answer = "hello" in a
a = set()
a.add([3, 4])
answer = [3, 4] in a
answer = {"a", 1, 2,} != { 2, 1, "a"}
answer = sum({1, 2, 3, 3, 3, 3, 3,})
a = {(1, 2), (3, 4)}
answer = (1, 2) in a
a = {(1, 2), (3, 4)}
answer = a[(1, 2)]
Next Exercise: Reverse