ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(int('0x1f', 16), int('1f', 16), int('0o17', 8))
  1. A. 31 31 15
  2. B. 31 31 17
  3. C. 0 31 15
  4. D. 31 31 0

Correct answer: A. 31 31 15

int with base 16 accepts a 0x prefix and the digits 1f, which is 31. The octal string 0o17 is 1 x 8 + 7 = 15.

More Python Programming questions

Exams that ask this topic