Question 9
Back to Exercise
What is the output of the following Python program?
print({x % 3 for x in range(10)}, sorted({len(w) for w in ["hi", "to", "sea", "a"]}))
- A {0, 1, 2, 0, 1, 2, 0, 1, 2, 0} [2, 2, 3, 1]
- B {1, 2, 3} [1, 2, 3]
- C {0, 1, 2} [2, 3, 1]
- D {0, 1, 2} [1, 2, 3] Correct
Correct Answer: Option D
Only the distinct remainders 0, 1, 2 and the distinct lengths 1, 2, 3 survive.
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!