計算期數
在真實情境中,這些函式常用來計算達成某個財務目標需要多久時間,不論是累積資產、為特定目標存錢,或是清償負債。
如果你每季存入 USD 1,250,並投資在一個年化報酬率 4.5%、按季複利的基金中,要多久才能存到 USD 30,000?
本練習屬於課程
使用 Python 進行債券評價與分析
練習說明
- 以別名
npf匯入numpy_financial套件。 - 使用
npf.nper()函式,根據上述資訊計算達成存款目標所需的期數,並將結果存到number_periods。 - 列印結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import numpy_financial package using alias npf
____
# Calculate how long it will take to reach the savings goal
number_periods = ____
# Print the result
____