ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print('%-6s|' % 'ab', '%6.2f|' % 3.14159, '%+.1e' % 12345.6789)
  1. A. ab | 3.15| +1.2e+04
  2. B. ab | 3.14| +1.2e+04
  3. C. ab | 3.14| +1.3e+04
  4. D. ab | 3.14| +1.2e+4

Correct answer: B. ab | 3.14| +1.2e+04

%-6s left-aligns ab in six columns, and %6.2f right-aligns 3.14 in six columns. The + flag with %e gives a signed value rounded to one decimal, which is +1.2e+04.

More Python Programming questions

Exams that ask this topic