ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('-0b11', 0), int('0_1', 0) if False else 0, int('1000'), int(' 0010 '))
  1. A. -3 0 1000 11
  2. B. -3 0 100 10
  3. C. -3 0 1000 10
  4. D. -2 0 1000 10

Correct answer: C. -3 0 1000 10

Base 0 reads the 0b prefix and the minus sign, giving -3. Surrounding whitespace is ignored, and leading zeros are allowed when converting a string with int().

More Python Programming questions

Exams that ask this topic