Cumulative payments and home equity
You are faithfully paying your mortgage each month, but it's difficult to tell how much of the house you actually own and how much interest you have paid in total over the years.
Use np.cumsum()
to add up all the interest payments and also to add up all the principal payments over time to see how your ownership changes over time.
Recall that np.cumsum()
performs a cumulative sum over time. Return a series of iterative sums instead of just a single number.
principal_paid
, interest_paid
, home_value
and down_payment_percent
from the previous exercise are available.
Este exercício faz parte do curso
Introduction to Financial Concepts in Python
Instruções do exercício
- Calculate your
cumulative_home_equity
over time usingnp.cumsum()
on the principal paid. - Repeat the process with
cumulative_interest_paid
. - Calculate your percentage home equity over time (don't forget to add the down payment!).
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
import numpy as np
# Calculate the cumulative home equity (principal) over time
cumulative_home_equity = ____
# Calculate the cumulative interest paid over time
cumulative_interest_paid = ____
# Calculate your percentage home equity over time
cumulative_percent_owned = ____ + (____/____)
print(cumulative_percent_owned)
# Plot the cumulative interest paid vs equity accumulated
plt.plot(cumulative_interest_paid, color='red')
plt.plot(cumulative_home_equity, color='blue')
plt.legend(handles=[interest_plot, principal_plot], loc=2)
plt.show()