ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(-7.5 // 2, -7.5 % 2)
- A. -3.0 -1.5
- B. -4.0 -1.5
- C. -3.0 0.5
- D. -4.0 0.5
Correct answer: D. -4.0 0.5
Float floor division also floors toward negative infinity: -7.5 / 2 = -3.75 floors to -4.0. The remainder takes the sign of the divisor, so -7.5 - (-4.0 * 2) = 0.5.
More Python Programming questions
- What is printed? python print(pow(3, 0, 1), pow(3, 0), 0 0)
- What is printed? python x = [1, 2, 3, 4, 5] print(x[-1:-4:-1], x[::-1][:2], x[::2][-1])
- What is printed? python import bisect a = [3, 1, 2, 5, 4] seen = [] inv = 0 for x in a: inv += len(seen) - bisect.bisectright(seen, x)…
- What is printed? python print(float('nan') == float('nan'), float('inf') - float('inf') != float('inf') - float('inf'))
- What is printed? python try: print([1, 2] < (1, 2)) except TypeError as e: print(e)
- What is printed? python print(sum(i for i in range(1, 101) if i % 3 == 0 or i % 5 == 0))