ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(max(map(len, ['ab', 'cde', 'f'])), sorted([[2, 1], [1, 5], [1, 2]]))
  1. A. 2 [[1, 2], [1, 5], [2, 1]]
  2. B. 3 [[1, 5], [1, 2], [2, 1]]
  3. C. 3 [[1, 2], [1, 5], [2, 1]]
  4. D. 3 [[2, 1], [1, 5], [1, 2]]

Correct answer: C. 3 [[1, 2], [1, 5], [2, 1]]

The longest string is cde with length 3. Lists compare element by element, so [1, 2] < [1, 5] < [2, 1].

More Python Programming questions

Exams that ask this topic