It is worth noting that floats comparison needs additional care when performed.
Look at the following example:
As of Python 3.5 (PEP-485), you can do such a comparison using
Look at the following example:
1.3 / 3.9 == 13 / 39
Output:False
This is due to the finite accuracy of representation float numbers in computer memory.As of Python 3.5 (PEP-485), you can do such a comparison using
math.isclose
function.import math math.isclose(1.3 / 3.9, 13 / 39)
Output:True