Question 15
Back to Exercise
Why does 0.1 + 0.2 == 0.3 give False?
- A Floats are stored as binary fractions, and 0.1, 0.2 and 0.3 cannot be represented exactly Correct
- B Python adds floats incorrectly
- C == cannot compare floats
- D The result is an int
Correct Answer: Option A
The sum is 0.30000000000000004. Compare with math.isclose() or use decimal.Decimal for exact decimal values.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!