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'])))
- A. 4 [3, 1, 0] 4
- B. 3 [3, 0, 1] 4
- C. 4 [3, 0, 1] 2
- 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
- What is printed? python print(float('1e-3') 1000 == 1, int(float('1e-3') 1000), round(float('1e-3') 1000))
- What is printed? python print(len({'a': 1, 'b': 2}), len({'a', 'a', 'b'}), len(dict.fromkeys('hello')))
- What is printed? python print(sorted({'b': 2, 'a': 3}.items(), key=lambda kv: kv[1])[0][0], list({'b': 2, 'a': 3})[-1])
- What is printed? python print(3 3 0, (3 3) 0, 0 3 0, (0 3) 0)
- What is printed? python import math print(math.isclose(0.1 + 0.2, 0.3), math.isclose(0.0, 1e-10), math.isclose(0.0, 1e-10, abstol=1e-9))
- What is printed? python print(int(9.99), int(-9.99), round(9.99), round(-9.99), 0)