Compound interest means that you add the interest (say, 2%) to a starting balance (say, $100) for a period of time (say it’s a year) to get a new balance ($102.00 in this example). During the next period of time, we apply the same interest rate to the new balance. In our example, during the second year, our 2% interest on $102 would give us $104.04 as our new balance. Write a function compound Interest that takes in an interest rate, a starting balance, and a number of years, then returns what the new balance would be. (Hint: Recursion can be useful here.)

What will be an ideal response?


```
def compoundInterest(interestRate, balance, years):
if years>0:
years-=1
balance += balance*interestRate
return compoundInterest(interestRate, balance, years)
else:
return balance
```

Computer Science & Information Technology

You might also like to view...

Explain what routine tasks are.

What will be an ideal response?

Computer Science & Information Technology

What is the data type of variable x in the following C++11 code:

``` int y= 2; double z = 3.5; auto x = z * y; ``` a) int b) double c) auto d)syntax error

Computer Science & Information Technology

The permutation cipher simply rearranges the values within a block to create the ciphertext.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The Gaussian setting distributes color values along a(n) ____________ for a speckled effect.?

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology