ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('0x1f', 16), int('0x1f', 0), int('  -12  '), int('1_000'))
  1. A. 31 31 -12 1000
  2. B. 0 31 -12 1000
  3. C. 31 31 -12 ValueError
  4. D. 31 31 -12 1000000

Correct answer: A. 31 31 -12 1000

int() strips surrounding whitespace, accepts a 0x prefix when the base is 16 (or 0, which auto-detects), and allows single underscores between digits since Python 3.6. The printed value of 1_000 is 1000.

More Python Programming questions

Exams that ask this topic