Get startedGet started for free

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.

This exercise is part of the course

Introduction to Financial Concepts in Python

View Course

Exercise instructions

  • Calculate your cumulative_home_equity over time using np.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!).

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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()
Edit and Run Code