Calculating Inflation, retirement and cost of living adjustments over 30 years

John Machin sjmachin at lexicon.net
Wed Jun 1 17:42:46 EDT 2005


rbt wrote:
> Is this mathematically correct?
> 
> 
> def inflation():
>     start = int(str.strip(raw_input("How much money do you need each 
> month at the start of retirement: ")))
>     inflation = float(str.strip(raw_input("What will inflation average 
> over the next 30 years(.03, .04, etc): ")))
> 
>     for x in xrange(30):
>         start = start*inflation+start
>         print start
> 
> inflation()

The *arithmetic* is tedious but "correct" -- we won't concern ourselves 
with rounding errors here. The *mathematics* might be better expressed as

required = start * (1.0 + inflation_rate_per_period) ** number_of_periods





More information about the Python-list mailing list