can someone help me with the formula to use with python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can someone help me with the formula to use with python

Write a function investment(PMT, n, i) that calculates your customer's savings at some point in the future, if: an amount is invested at the END of every year, starting with amount of PMT at the end of this year, at an interest rate of i% per year, compounded annually, the investment amount doubles every second year (cumulatively). IMPORTANT: Your function may not call any of the other functions you've defined in this project. ### START FUNCTION 7 def investment(PMT, n, i): # YOUR CODE HERE return round(investment_balance, 2) ### END FUNCTION 7 IMPORTANT: Your function needs to return an float value correctly rounded to 2 decimal places. If your answer is not rounded correctly to 2 decimal places, you will receive 0 for the question. Make sure that the following tests all give a True result: investment(15000, 30, 0.1045) == 1954935238.47 investment(10000, 40, 0.1045) == 41728281751.16

24th Sep 2018, 12:32 PM
Thendo
1 Answer
+ 3
Here is a possible solution. Please check it out, if it is correct. def investment(PMT, n, i): investment_balance = 0.00 for k in range(1,n+1): if k%2 == 0: PMT = PMT*2 investment_balance = investment_balance * (1.0 + i) + PMT return round(investment_balance, 2) print(investment(15000.0, 30, 0.1045) == 1954935238.47) print(investment(10000.0, 40, 0.1045) == 41728281751.16)
27th Sep 2018, 9:29 PM
P.W.R.
P.W.R. - avatar