What is the output of `print(0.1 + 0.2 == 0.3)` in Python?

Python Professional Hard

Python Professional — Hard

What is the output of `print(0.1 + 0.2 == 0.3)` in Python?

Key points

  • Floating-point arithmetic can lead to small inaccuracies
  • Comparing floating-point numbers for equality can be tricky
  • Python uses binary floating-point arithmetic
  • Precision issues can arise when working with floating-point numbers

Ready to go further?

Related questions