MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Bond Valuation and Analysis in Python

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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 dan Jalankan Kode