Problem
Der Float-Typ bringt einige Präzisionsprobleme mit sich.
>>> .1 + .1 + .1 == .3
False
>>> .1 + .1 + .1
0.30000000000000004
Aufgrund der Float-Näherung ist die Gleichung nicht gleich 3.
Lösung
Wenn es auf Präzision ankommt, verwenden Sie demical statt float.
>>> from decimal import Decimal
>>> Decimal(".1") + Decimal(".1") + Decimal(".1") == Decimal(".3")
True
>>> Decimal(".1") + Decimal(".1") + Decimal(".1")
0.3