ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(f'{1234567.891:_.2f}', f'{255:#x}', f'{5:03d}', f'{-5:03d}', f'{-5:+04d}')
  1. A. 1_234_567.89 0xff 005 -05 -005
  2. B. 1_234_567.9 0xff 005 -05 -005
  3. C. 1_234_567.89 0o377 005 -05 -005
  4. D. 1_234_567.89 0xff 5 -05 -005

Correct answer: A. 1_234_567.89 0xff 005 -05 -005

The _ flag groups thousands with underscores, and the # flag adds the 0x prefix. Zero-padding with width 3 counts the minus sign, so -5 becomes -05 and the + variant gives -005.

More Python Programming questions

Exams that ask this topic