ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int('0x1A', 16), int('1A', 16), int('0x1A', 0))
  1. A. 26 26 0
  2. B. 0 26 26
  3. C. 26 0 26
  4. D. 26 26 26

Correct answer: D. 26 26 26

int with base 16 accepts an optional 0x prefix, so both forms give 26. Base 0 reads the prefix to pick the base.

More Python Programming questions

Exams that ask this topic