开始使用免费开始使用

预测因通胀而上升的支出

您还需要假设由于通胀,您的每月支出将以每年平均 2.5% 的速度上升。这意味着随着时间推移,生活成本会更高——每年为相同的支出支付更高的价格。好消息是,您的薪资增长速度快于通胀,这表示您每月应有更多资金可以存入储蓄。

上一练习中的变量 monthly_expensesforecast_months 可用。

本练习是课程的一部分

Python 金融概念入门

查看课程

练习说明

  • 将年度通胀率设为 2.5%。
  • 推导等效的月度通胀率。
  • 预测随时间推移的累计通胀增长。
  • 考虑通胀导致的增长,推导您的每月支出。

交互式实操练习

通过完成这段示例代码来试试这个练习。

import numpy as np

# Set the annual inflation rate
annual_inflation = ____

# Calculate the equivalent monthly inflation rate
monthly_inflation = ____

# Forecast cumulative inflation over time
cumulative_inflation_forecast = ____

# Calculate your forecasted expenses
expenses_forecast = ____

# Plot the forecasted expenses
plt.plot(expenses_forecast, color='red')
plt.show()
编辑并运行代码