Question 8
Back to Exercise
What is the output of the following Python program?
s = {1}
s.update([2, 3], (4,))
s.add((5, 6))
print(len(s), (5, 6) in s, 5 in s)
- A 6 False True
- B 5 True False Correct
- C 7 True True
- D 5 False True
Correct Answer: Option B
update() adds each element of each iterable (2, 3, 4); add() inserts the tuple (5, 6) as a single element.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!