ProgrammingVery hardProduct-company MCQ pattern
What is printed on the first line?
What is printed on the first line?
print(2**63 * 2**-63 == 1.0, 2**64 + 1.0 - 2**64, (2**64 + 1) - 2**64) print(float(2**64 + 1) - float(2**64))
- A. True 2.0 1
- B. False 0.0 1
- C. True 0.0 2
- D. True 0.0 1
Correct answer: D. True 0.0 1
2**64 + 1.0 loses the +1 because the float cannot hold it, but the all-int expression keeps it exactly. Converting both operands to floats first gives 0.0 as well.
More Python Programming questions
- What is printed on the first line? python print(7 % -3, -7 % 3, 7 % 3, -7 % -3) print(-7 // -3, 7 // -3, -7 // 3)
- What is printed on the second line? python def mod(a, m): r = a % m return r + m if r < 0 else r print(mod(-1, 5), mod(-5, 5), mod(-6, 5))…
- What is printed on the first line? python M = 109 + 7 print((-1) % M, (262) % M, pow(3, M - 2, M) 3 % M) print(((-5) % 3) ((-5) % 3), (-5…
- What is printed on the second line? python a, b = -13, 4 print(a // b, a % b, a // b b + a % b == a) print(int(a / b), int(-3.25), -3.25…
- What is printed on the first line? python n = -17 print(n >> 2, n // 4, n & 3, n % 4) print(n << 1, (n << 1) >> 1 == n, ~n)
- What is printed on the first line? python x = 1 for in range(70): x = 2 print(x, x.bitlength(), x == 270) print(x.bitlength() - 1, (x…