ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(max(map(len, ['ab', 'cde', 'f'])), sorted([[2, 1], [1, 5], [1, 2]]))
- A. 2 [[1, 2], [1, 5], [2, 1]]
- B. 3 [[1, 5], [1, 2], [2, 1]]
- C. 3 [[1, 2], [1, 5], [2, 1]]
- 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
- What is printed? python print(list(enumerate('ab', start=5)))
- What is printed? python print(int(3.99999999999999999), int(-0.9))
- What is printed? python print('{0}{1}{0}'.format('a', 'b'), '{:>3}'.format(7), '%%%d' % 5)
- What is printed? python print(bin(5 << 2), 5 >> 1, -5 >> 1, -5 // 2)
- What is printed? python print(1 if 0 else 2 if 3 else 4, 0 or '' or 'z', 0 and 'z')
- What is printed? python a = [1, 2, 3] b = a 2 b[0] = 9 print(a, b)