ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(max(map(len, ['aa', 'b', 'ccc'])))
- A. 2
- B. 1
- C. 6
- D. 3
Correct answer: D. 3
map applies len to each string, giving 2, 1 and 3, and max returns the largest length.
More Python Programming questions
- What is printed? python print(bool(range(0)), bool(range(1)), bool({0: 0}))
- What is printed? python print(sorted([True, 0, 2, False]))
- What is printed? python print(7 // 2 2, 7 / 2 2, 2 3 2)
- What is printed? python print([1, 2] < [1, 3], [1, 2] < [1], 'b' > 'abc')
- What is printed? python print(isinstance([], list) and isinstance((), tuple), type([]) == list)
- What is printed? python print(''.join(sorted('hello', key=lambda c: c in 'aeiou')))