ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
print(0.1 * 3, round(0.1 * 3, 2), 1.1 + 2.2 == 3.3, round(1.1 + 2.2, 1) == 3.3)
  1. A. 0.3 0.3 True True
  2. B. 0.30000000000000004 0.3 True True
  3. C. 0.30000000000000004 0.3 False True
  4. D. 0.3 0.30 False True

Correct answer: C. 0.30000000000000004 0.3 False True

0.1 is not exactly representable in binary, so 0.1 * 3 and 1.1 + 2.2 carry a tiny error and the equality fails; rounding first makes the comparison safe.

More Python Programming questions

Exams that ask this topic