Search for question
Question

Q2.7.2 The following code snippet attempts to calculate the balance of a savings account with an annual interest rate of 5% after four years, if it starts with a balance of $100. >>> balance = 100 >>> def add interest (balance, rate): balance balance * rate 100 >>> for year in range (4): add interest (balance, 5) print('Balance after year {} ${.2f}'.format(year + 1, balance)) Balance after year 1: $100.00 Balance after year 2: $100.00 Balance after year 3: $100.00 Balance after year 4: $100.00 Explain why this doesn't work and then provide a working alternative.

Fig: 1