ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('%x' % 255, '%X' % 255, '%#o' % 8, '%+d' % 0)
  1. A. ff FF 010 0
  2. B. ff FF 0o11 0
  3. C. ff fe 0o10 0
  4. D. ff FF 0o10 +0

Correct answer: D. ff FF 0o10 +0

%x gives lowercase hex and %X uppercase. The # flag adds the 0o prefix for octal, and the + flag shows a sign even for zero.

More Python Programming questions

Exams that ask this topic