Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Try printing the values of a**2 + b**2 and c**2, and you'll see that they're sometimes close but not equal. The general consensus is to never compare floating point numbers for equality, or at least using ==. If you really want to do it, try checking out the decimal module or other ways of checking if two floating point numbers are close by a certain precision.
5th Oct 2020, 4:59 AM
Zerokles
Zerokles - avatar