ProgrammingModerateProduct-company MCQ pattern

What is printed?

What is printed?
print(0.1 + 0.2 == 0.3, abs(0.1 + 0.2 - 0.3) < 1e-9)
  1. A. False False
  2. B. True True
  3. C. True False
  4. D. False True

Correct answer: D. False True

0.1 and 0.2 have no exact binary form, so their sum is 0.30000000000000004, not 0.3, and == is False. Comparing within a small tolerance (or using math.isclose) gives True.

More Python Programming questions

Exams that ask this topic