ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(max([1, 5, 3], key=lambda v: -v))
  1. A. 5
  2. B. 3
  3. C. -7
  4. D. 1

Correct answer: D. 1

The key negates each value, so the largest key belongs to the smallest value, 1. max returns the original element, not its key.

More Python Programming questions

Exams that ask this topic