Python学习记录(二)

When investing money, an important concept to know is compound interest. The equation FV = PV (1+rate)periods relates the following four quantities.

  • The present value (PV) of your money is how much money you have now.

  • The future value (FV) of your money is how much money you will have in the future.

  • The nominal interest rate per period (rate) is how much interest you earn during a particular length of time, before accounting for compounding. This is typically expressed as a percentage.

  • The number of periods (periods) is how many periods in the future this calculation is for.


Finish the following code, run it, and submit the printed number. Provide at least four digits of precision after the decimal point.

def future_value(present_value, annual_rate, periods_per_year, years):
    rate_per_period = annual_rate / periods_per_year
    periods = periods_per_year * years
    
    # Put your code here.

print "$1000 at 2% compounded daily for 3 years yields $", future_value(1000, .02, 365, 3)

Before submitting your answer, test your function on the following example. future_value(500, .04, 10, 10) should return 745.317442824.


print present_value * ( 1 + rate_per_period) ** periods 


本来很简单一道题,没看懂题,愣了好久,数学中的专业术语英文意思还真是不太懂。


CodeSkulptor地址:http://www.codeskulptor.org/#user38_RQd7eoNicM_0.py

转载于:https://my.oschina.net/shiftwang/blog/359118

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值