ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(max('apple', 'banana', key=len), max('pear', 'fig', key=len), min('bb', 'aa', 'c', key=len))
  1. A. banana pear fig
  2. B. banana pear c
  3. C. apple pear c
  4. D. banana fig c

Correct answer: B. banana pear c

With key=len, max compares word lengths, so banana (6 letters) beats apple (5). min returns the shortest word, which is the one-letter 'c', and ties keep the first item found.

More Python Programming questions

Exams that ask this topic