from jhplot import *
principal=10000.0 # starting principal (initial investment)
rate=0.05 # percentage of interest rate
maxyear=50 # maximal years
c1=HPlot()
c1.visible(); c1.setAutoRange()
c1.setMarginLeft(100)
p1=P1D("Value $$")
p1.setDrawLine(1) # show as connected lines
for year in range( 1, 21 ):
amount = principal*(1.0+rate)**year
print "%4d%21.2f" % ( year, amount )
p1.add(year,amount)
c1.setNameX("year")
c1.setNameY("balance $$")
c1.draw(p1)
Ads help maintain this website.