ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('{:+}'.format(-0.0), '{:+}'.format(0), '{:+.1f}'.format(-0.04), '{:+}'.format(5))
  1. A. -0.0 +0 -0.0 +6
  2. B. -0.0 0 -0.0 +7
  3. C. -0.0 +0 -0.0 +5
  4. D. +0.0 +0 -0.0 +9

Correct answer: C. -0.0 +0 -0.0 +5

The + sign flag shows a sign for every number, and negative zero keeps its minus sign. The integer 0 gets a plus, and -0.04 rounds to -0.0 at one decimal.

More Python Programming questions

Exams that ask this topic