Question 9
Back to Exercise
What is the output of the following Python program?
d = {"a": 3, "b": 7, "c": 5}
print(max(d, key=lambda k: d[k]), min(d.items(), key=lambda kv: kv[1]), max(d))
- A b ('a', 3) c Correct
- B 7 ('a', 3) c
- C b ('a', 3) b
- D c ('a', 3) c
Correct Answer: Option A
With a key, items are compared by their values. max(d) without a key compares the keys themselves: "c" is the largest letter.
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!