ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(bin(5), oct(8), hex(16), int('101', 2) + int('7', 8))
  1. A. 0b101 0o8 0x16 12
  2. B. 0b101 0o10 0x10 5
  3. C. 0b11 0o10 0x10 12
  4. D. 0b101 0o10 0x10 12

Correct answer: D. 0b101 0o10 0x10 12

bin(5) is 0b101, oct(8) is 0o10 and hex(16) is 0x10. int('101', 2) is 5 and int('7', 8) is 7, so the sum is 12.

More Python Programming questions

Exams that ask this topic