ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('%d%%' % 50, '%x' % 255, '%o' % 8, '%e' % 12345.678)
  1. A. 50% ff 10 1.2346e+04
  2. B. 50% ff 10 1.234568e+04
  3. C. 50% ff 8 1.234568e+04
  4. D. 50% ff 10 1.234568e+4

Correct answer: B. 50% ff 10 1.234568e+04

%% prints one percent sign, %x gives lowercase hexadecimal, and %o gives octal, so 8 is 10 in base 8. The %e default has six digits after the point, which gives 1.234568e+04.

More Python Programming questions

Exams that ask this topic