ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(f"{1234567.891:,.2f}", f"{255:b}", f"{-5:+d}")
  1. A. 1234567.89 11111111 -5
  2. B. 1,234,567.9 11111111 -5
  3. C. 1,234,567.89 255 -5
  4. D. 1,234,567.89 11111111 -5

Correct answer: D. 1,234,567.89 11111111 -5

The comma option groups thousands and .2f rounds to two decimals. b formats in binary. A + sign applies only to nonnegative numbers, and -5 keeps its minus sign.

More Python Programming questions

Exams that ask this topic