以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 网友互助 』  (http://bbs.xml.org.cn/list.asp?boardid=76)
----  COMP SCI课的问题.  (http://bbs.xml.org.cn/dispbbs.asp?boardid=76&rootid=&id=77900)


--  作者:yvonne0
--  发布时间:10/22/2009 10:17:00 AM

--  COMP SCI课的问题.
拜托大家教我一下该怎么做..谢谢

the growth of an investment a over n years with interest rate r is calculated by a*(1+r/100)^n. For example if a=$100,r=5%,and n=4 years,then the growth =100*(1+0.05)^4,which is approximately $121.55.  Banks sometims offer investments with increasing interest rates, e.g.4% in the first year,4% in the second year, 5% in third year, 7% in fourth year. For an investment of $100, the growth would be 100*1.04*1.04*1.05*1.07,which is approximately$121.52 . Write a procedure(function) in python that calculates the growth given the investment and a list with yearly interest rates. The result should be rounded to two decimal places. The functionshould be called growth used as follows:
>>> growth(100,[4,4,5,7])
121.52


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms