ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(max(len(w) for w in 'the quick brown fox'.split()), [w for w in 'the quick brown fox'.split() if len(w) == 5])
- A. 5 ['quick']
- B. 5 ['quick', 'brown']
- C. 4 ['quick', 'brown']
- D. 5 ['brown', 'quick']
Correct answer: B. 5 ['quick', 'brown']
The longest word has five letters, and both quick and brown have five letters. The list keeps them in their original order.
More Python Programming questions
- What is printed? python print(''.join(sorted('hello', key=lambda c: (c not in 'aeiou', c))))
- What is printed? python print(round(0.1 0.1, 3) == 0.01, round(2.345, 2), round(2.355, 2))
- What is printed? python print(max(1, 2.0, True), min([0.0, -0.0, 0]), sum([]) == 0.0)
- What is printed? python print(10100 // 1098, (10100) % 97 == pow(10, 100, 97))
- What is printed? python print(sorted(['b10', 'b9', 'a10'], key=lambda s: (s[0], int(s[1:]))))
- What is printed? python print(sorted('bAcB', key=str.upper), sorted('bAcB'))