ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(f"{3.14159:.2f}|{42:>5}|{'ab':*^6}|{255:#x}|{1234567:,}")
  1. A. 3.14|42 |**ab**|0xff|1,234,567
  2. B. 3.14| 42|ab****|ff|1,234,567
  3. C. 3.14| 42|**ab**|0xff|1,234,567
  4. D. 3.142| 42|**ab**|0xff|1234567

Correct answer: C. 3.14| 42|**ab**|0xff|1,234,567

.2f rounds to two decimals; >5 right-aligns in width 5 (3 spaces then 42); *^6 centres 'ab' in width 6 with * fill; #x is hexadecimal with the 0x prefix; the , option inserts thousands separators.

More Python Programming questions

Exams that ask this topic