ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print(int(True), int("0b101", 0), int("0o17", 0), int("ff", 16), int("  12\n"), int(" 0x10 ", 16))
  1. A. 1 101 17 255 12 16
  2. B. 1 5 15 255 ValueError 16
  3. C. 1 5 15 255 12 ValueError
  4. D. 1 5 15 255 12 16

Correct answer: D. 1 5 15 255 12 16

With base 0, int infers the base from the prefix. Surrounding whitespace is allowed, and with base 16 the 0x prefix is also accepted.

More Python Programming questions

Exams that ask this topic