ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(min([(1, 'b'), (1, 'a')], key=lambda t: t[0]), max(['aa', 'b', 'cc'], key=len))
  1. A. (1, 'a') cc
  2. B. (1, 'b') cc
  3. C. (1, 'a') aa
  4. D. (1, 'b') aa

Correct answer: D. (1, 'b') aa

min and max return the first item that attains the best key, so the tie on key 1 gives (1, 'b'). For max with key=len, 'aa' is the first longest item among 'aa' and 'cc'.

More Python Programming questions

Exams that ask this topic