Solution: Calculate Compound Interest
Look at the recursive solution to calculating compound interest.
We'll cover the following...
Solution
Press + to interact
# method definition with parametersdef compound_interest(principal_amount, rate, years)# base caseif years == 0return principal_amountelse# calculation of compound interest using recursionprincipal_amount = principal_amount + rate * principal_amountcompound_interest(principal_amount, rate, years - 1)endend
Explanation
Line 8: ...