ProgrammingModerateTCS NQT · Infosys
What is printed on the first line?
What is printed on the first line?
print(int('1' * 19) + 1, 10**18 * 10, 9_223_372_036_854_775_807 + 1 > 2**63 - 1)
print(2**100 // 2**98, (2**100) >> 98, 2**100 % 2**98)- A. 1111111111111111112 10000000000000000000 True
- B. 1111111111111111111 10000000000000000000 True
- C. 1111111111111111112 1000000000000000000 True
- D. 1111111111111111112 10000000000000000000 False
Correct answer: A. 1111111111111111112 10000000000000000000 True
Python ints are unbounded, so the 64-bit boundary has no effect and the comparison is True. The result of a % b for exact powers of two is 0.
More Python Programming questions
- What is printed? python print(0b1111 ^ 0b1010 & 0b0110, (0b1111 ^ 0b1010) & 0b0110, 6 & 3 | 4 ^ 1)
- What is printed? python print(1 << 2 + 1, (1 << 2) + 1, 4 >> 1 - 1, 2 3 % 4 2 // 3)
- What is printed on the first line? python print(0.5 + 0.25 == 0.75, 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0)…
- What is printed? python print(round(0.5), round(1.5), round(2.5), round(-2.5), round(2.5 + 1e-15))
- What is printed? python print(round(12345, -2), round(12350, -2), round(12250, -2), round(-1234.5, -1))
- What is printed? python print(format(1234.5678, '.2f'), format(1234.5678, '.2e'), format(0.000012345, '.3g'), format(12345.6789, ',.1f'))