计算每期还款额
您在现实中可能会遇到的另一个问题是:在给定时间内达到某个财务目标,每月需要储蓄多少钱。
前面您已经看到:若要在 10 年内偿还 275,000 美元的按揭贷款,年利率 3.5%,按月复利,每月需要支付 2,719 美元。
如果改为用 20 年来还清这笔按揭,请计算现在每月需要支付多少。
本练习是课程的一部分
用 Python 进行债券定价与分析
练习说明
- 以别名
npf导入numpy_financial库。 - 使用
npf.pmt()函数计算所需的每月还款额,并将其保存到required_return。 - 打印结果。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import the numpy_financial package using the alias npf
____
# Calculate monthly payment required
required_payment = ____
# Print the result
____