ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(round(1234.5678, -2), round(-1.5), round(-2.5), round(0.1 + 0.2, 1))
  1. A. 1200.0 -2 -2 0.3
  2. B. 1200 -2 -2 0.3
  3. C. 1200.0 -1 -2 0.3
  4. D. 1234.57 -2 -2 0.3

Correct answer: A. 1200.0 -2 -2 0.3

A float rounded with a negative digits argument stays a float, here 1200.0. round(-1.5) gives -2 and round(-2.5) gives -2, both to the even number. 0.1 + 0.2 rounded to one place is 0.3.

More Python Programming questions

Exams that ask this topic