ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(-2**63 // -1 == 2**63, abs(-2**63) == 2**63, (2**63) * (2**63) > 2**127, 2**63 * 2**63 == 2**126)
  1. A. True True False True
  2. B. True True True True
  3. C. True False False True
  4. D. True True False False

Correct answer: A. True True False True

Python ints never overflow, so 2**63 squared is exactly 2**126, which is less than 2**127. Dividing -2**63 by -1 gives 2**63 with no wraparound.

More Python Programming questions

Exams that ask this topic