programming loop sample (Python)
Problem 4.) Each month, Pytho puts $$100 into her bank account at the beginning of each month. Initially, she has $$100 in the account, marking her first deposit. At the end of each month, she earns 2% interest on her current balance, before the next deposit. Then, she makes her $$100 deposit. She would like a function that gives her balance after ?n months. Complete the function below so that the function returns the final balance. Keep in mind that ?=0t=0 corresponds to the initial month, when only one $$100 deposit has been made. Thus, she will have earned interest only on her initial $$100 deposit and she will have made one more deposit of $$100 at ?=1t=1 - that is, her balance should be $$202.
final_balance(360)
OUTPUT: 6357561.75
#if there is any error, please tell in comments, and provide the function outline provided to you
def final_balance(n):
rate = .02
balance = 0
for i in range(0,n):
balance+=100
balance+=balance*rate
return balance
Get Answers For Free
Most questions answered within 1 hours.