Open this example in the interactive library
Source code
from decimal import Decimal
print(Decimal('0.1') + Decimal('0.2'))Sample output
0.3

Use exact decimal arithmetic. A self-contained example using the Python standard library.
Open this example in the interactive library
from decimal import Decimal
print(Decimal('0.1') + Decimal('0.2'))0.3