ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(round(-0.5), round(0.5), round(1.5), round(-1.5))
- A. 0 1 2 -1
- B. 0 0 2 -1
- C. 0 0 2 -2
- D. -1 1 2 -2
Correct answer: C. 0 0 2 -2
round sends ties to the nearest even integer. -0.5 and 0.5 go to 0, and 1.5 and -1.5 go to 2 and -2.
More Python Programming questions
- What is printed? python import bisect print(bisect.bisectright([1, 2, 2, 3], 2, lo=2))
- What is printed? python print(2 3 0, (2 3) 0)
- What is printed? python print(7 & 3 | 4 ^ 1)
- What is printed? python print(5 <= 5 < 6 != 7, 1 < 2 > 3)
- What is printed? python print(len('') or 'empty', [] or 'none')
- What is printed? python a = [1, 2, 3] b = a[:] a.append(4) print(len(a), len(b))