ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('0o777', 8) == 511, int('777', 8) - int('0o777', 0))
  1. A. True 511
  2. B. False 0
  3. C. True 0
  4. D. True 510

Correct answer: C. True 0

int accepts a 0o prefix when the base matches, and base 0 reads the prefix to choose the base. Both conversions give 511, so their difference is 0.

More Python Programming questions

Exams that ask this topic