ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(oct(64), hex(-255), bin(0))
  1. A. 100 -0xff 0b0
  2. B. 0o64 -0xff 0b0
  3. C. 0o100 -0xff 0b0
  4. D. 0o100 0xfe 0b0

Correct answer: C. 0o100 -0xff 0b0

oct and hex add their prefixes. The 0o prefix shows 64 as 100 in base 8. A negative number keeps its minus sign in front of the prefix.

More Python Programming questions

Exams that ask this topic