principal.py源代码分析

 

principal = 1000.0 # starting principal,本金

rate = .05 # interest rate,利率

print "Year %21s" % "Amount on deposit"#打印的头

for year in range( 1, 11 ):

amount = principal * ( 1.0 + rate ) ** year

#计算每年的本息和

print "%4d%21.2f" % ( year, amount )

#打印每年的本息和

你可能感兴趣的:(源代码)