ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int('0b1011', 2), int('0b1011', 0), int('z', 36), int('1011', 2))
  1. A. 11 11 35 11
  2. B. 11 1011 35 11
  3. C. 11 11 36 11
  4. D. 1011 11 35 11

Correct answer: A. 11 11 35 11

int with base 2 accepts an optional 0b prefix, so '0b1011' gives 11. Base 0 detects the prefix and gives the same value. 'z' is digit 35 in base 36, and '1011' in base 2 is 11.

More Python Programming questions

Exams that ask this topic