開始使用免費開始

計算複利

複利在現實世界中更常見,而且在計算債券價格時是關鍵概念,你會在下一章看到它的應用。

現在想像同一個儲蓄帳戶每年支付 3% 的複利,而不是單利。與先前相同,你投入 USD 10,000,投資期間為 10 年。

本練習屬於課程

使用 Python 進行債券評價與分析

檢視課程

練習說明

  • 分別將現值、利率與期數指定給 pvrn
  • 計算 10 年後這個儲蓄帳戶的金額,並印出結果。
  • 計算並印出這 10 年間賺到的利息金額。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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)
編輯並執行程式碼