ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(10**18 + 1 == 1000000000000000001, 2**31 - 1 + 1, -(2**31), (2**31) * (2**31) == 2**62)
  1. A. True 2147483647 -2147483648 True
  2. B. True 2147483648 -2147483648 True
  3. C. True 2147483648 -2147483647 True
  4. D. False 2147483648 -2147483648 True

Correct answer: B. True 2147483648 -2147483648 True

Python integers never overflow, so 2**31 - 1 + 1 is exactly 2**31 and the product of two 2**31 values equals 2**62. Fixed-width C or Java ints would wrap here.

More Python Programming questions

Exams that ask this topic