First page Back Continue Last page Overview Graphics
A Simple Tax Calculation
We want to calculate a 5% tax (rounded to the nearest cent) on a $0.70 phone call:
Using the decimal module:
>>> import decimal
>>> (decimal.Decimal('0.70') *
... decimal.Decimal('.05'))
Decimal("0.0350")
Rounds to 4 cents.
Notes: