Get startedGet started for free

Calculating compound interest

Compound interest is much more applicable in the real world and is an important feature in calculating the price of a bond, as you will see in the next chapter.

Now imagine the same savings account pays 3% per year as compound interest instead of simple interest. As before, you invest USD 10,000 for a period of ten years.

This exercise is part of the course

Bond Valuation and Analysis in Python

View Course

Exercise instructions

  • Assign the present value, rate, and number of periods to pv, r, and n, respectively.
  • Find how much money the savings account will have after ten years and print the result.
  • Calculate and print the amount of interest earned over the ten years.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Assign present value, rate and number of periods
pv = ____
r = ____
n = ____

# Calculate the value of the savings account
fv = ____
print(fv)

# Calculate the total amount of compound interest earned
compound_interest = ____
print(compound_interest)
Edit and Run Code