ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(sum(range(5)) / len(range(5)), sum([1, 2, 3, 4]) // 4, 9 // 2 * 2 + 9 % 2)
- A. 2 2 9
- B. 2.0 2 9
- C. 2.0 3 9
- D. 2.5 2 9
Correct answer: B. 2.0 2 9
The average of 0 to 4 is 10 / 5 = 2.0 as a float. Integer floor division of 10 by 4 is 2 for the list sum, and 9 // 2 * 2 + 9 % 2 gives 8 + 1 = 9.
More Python Programming questions
- What is printed? python print(str(3) + str(4) == '34', 3 + 4 == 7, '3' + '4' == 7)
- What is printed? python print(len(''), len(' '), len('t'), ''.isspace())
- What is printed? python print(1 + '1' if False else '1' + str(1), '3' 2 + str(4 - 1), int('3' 2) + 4 - 1)
- What is printed? python print(bool(0 or '' or []), bool([[]]), bool([0]), bool(' '.strip()))
- What is printed? python print(round(2.345, 2), round(2.355, 2), round(7.5), round(8.5))
- What is printed? python print(len([x for x in range(3) for y in range(x)]), [x y for x in range(3) for y in (1, 2) if x], sum(1 for i in…