ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(oct(0o17 + 0b11), 0x10 | 0o7, 1_0 + 0x_1)
  1. A. 0o21 23 11
  2. B. 0o22 22 11
  3. C. 0o22 23 10
  4. D. 0o22 23 11

Correct answer: D. 0o22 23 11

0o17 is 15 and 0b11 is 3, so the sum is 18, which is 0o22 in octal. 0x10 | 0o7 is 16 | 7 = 23, and the literals 1_0 and 0x_1 give 10 + 1.

More Python Programming questions

Exams that ask this topic