ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(max(['abc', 'x', 'yz'], key=len), min(['b', 'B', 'a']))
  1. A. abc a
  2. B. x B
  3. C. abc B
  4. D. yz B

Correct answer: C. abc B

max with key=len picks the longest string, abc. For plain min, uppercase letters have smaller code points than lowercase ones, so 'B' (66) is less than 'a' (97) and 'b' (98).

More Python Programming questions

Exams that ask this topic