ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print('%x' % -255, '%o' % 8, '%e' % 0.0, '%.0e' % 12345)
  1. A. -fe 10 0.000000e+00 1e+04
  2. B. -ff 10 0.000000e+00 1.2e+04
  3. C. -ff 10 0.000000e+00 1e+04
  4. D. -ff 8 0.000000e+00 1e+04

Correct answer: C. -ff 10 0.000000e+00 1e+04

%x of a negative number keeps the minus sign, giving -ff rather than a two's complement form. %o of 8 is 10 in octal, and %.0e of 12345 rounds to one digit, 1e+04.

More Python Programming questions

Exams that ask this topic