ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(round(7.5), round(6.5), round(-7.5), round(7.5000001))
- A. 8 6 -8 7
- B. 8 6 -7 8
- C. 7 6 -8 8
- D. 8 6 -8 8
Correct answer: D. 8 6 -8 8
Exact halves go to the even neighbour, so 7.5 becomes 8 and 6.5 becomes 6. 7.5000001 is above the half-way point and rounds up to 8.
More Python Programming questions
- What is printed? python print(-7.5 % 2, 7.5 % -2, -0.0 % 3)
- What is printed? python words = 'the quick brown the lazy the'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1…
- What is printed? python print('%.3f' % 1.0005, '%.1f' % 0.25, '%.1f' % 0.35, round(0.35, 1))
- What is printed? python from collections import Counter c = Counter('mississippi') print(c.mostcommon(2), sorted(c.items(), key=lambda kv…
- What is printed? python x = 5 y = x if x > 3 else 0 + 1 if x else -1 print(y, (lambda a, b=2: a b)(3), (lambda a: sum(a))(1, 2, 3))
- What is printed? python print(sorted([2.0, 2, True, 1.5]))