ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(max(map(len, ['abc', 'de', 'fghi'])), list(map(len, ['abc', '', 'x'])), sum(map(len, ['ab', 'cd'])))
  1. A. 4 [3, 1, 0] 4
  2. B. 3 [3, 0, 1] 4
  3. C. 4 [3, 0, 1] 2
  4. D. 4 [3, 0, 1] 4

Correct answer: D. 4 [3, 0, 1] 4

The longest string is fghi with four characters. Empty strings have length 0, and the two-letter strings contribute 2 + 2 = 4.

More Python Programming questions

Exams that ask this topic