ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(max('the', 'a', key=len), min(['b', 'B'], key=str.lower), ''.join(sorted('cab')), 'cab'.upper().swapcase())
  1. A. the b abd cab
  2. B. the b abc cab
  3. C. the b cba cab
  4. D. the z abc cab

Correct answer: B. the b abc cab

max by length picks the longest word, the. min by casefold ties b and B, and min keeps the first of equal items, which is b. Sorting the letters gives abc, and swapcase of CAB is cab.

More Python Programming questions

Exams that ask this topic