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

你可能感兴趣的:(python)