ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(int('0b11', 0) + int('0o11', 0) + int('0x11', 0), int('11', 16), int('-0b11', 0))
  1. A. 29 16 3
  2. B. 28 17 -3
  3. C. 27 17 -3
  4. D. 29 17 -3

Correct answer: D. 29 17 -3

The three prefixed literals are 3, 9 and 17, which sum to 29. int('11', 16) is 17, and the sign is kept when the base prefix is read with base 0.

More Python Programming questions

Exams that ask this topic