ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('0b101', 0), int('0o17', 8), int('z', 36), int('-0'), int('+7'))
  1. A. 5 16 35 0 7
  2. B. 5 15 35 1 7
  3. C. 6 15 35 0 7
  4. D. 5 15 35 0 7

Correct answer: D. 5 15 35 0 7

Base 0 chooses the base from the prefix, so 0b101 is 5. Base 36 uses letters for digits up to z, which is 35. A leading sign is allowed, so '+7' is 7 and '-0' is 0.

More Python Programming questions

Exams that ask this topic