ProgrammingVery hardTCS NQT · Infosys

What is printed?

What is printed?
print(f'{1234.5:,.2f}', f'{0.000123:.2e}', f'{-0.0:+.1f}', f'{0x123456:_x}')
  1. A. 1,234.50 1.23e-4 +0.0 12_3456
  2. B. 1,234.50 1.23e-04 -0.0 123456
  3. C. 1,234.50 1.23e-04 -0.0 12_3456
  4. D. 1,234.5 1.23e-04 -0.0 12_3456

Correct answer: C. 1,234.50 1.23e-04 -0.0 12_3456

The comma flag groups thousands and .2f keeps two decimals. The e format writes at least two exponent digits, and the sign of -0.0 is kept. The underscore flag groups hexadecimal digits in fours from the right, so 0x123456 becomes 12_3456.

More Python Programming questions

Exams that ask this topic