ProgrammingHardCodeforces-style · placement coding round

What is printed?

What is printed?
print(max(range(7), key=lambda i: (i % 3, i)))
  1. A. 5
  2. B. 2
  3. C. 6
  4. D. 4

Correct answer: A. 5

The key pairs each value's remainder mod 3 with the value itself. The largest key is (2, 5), so 5 is the answer.

More Python Programming questions

Exams that ask this topic