ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. True False True

Doubling 0.1 and 0.2 is exact in binary, so those sums match the literals. Adding 0.1 three times accumulates rounding error, so the total misses 0.3.

More Python Programming questions

Exams that ask this topic