Aan de slagGa gratis aan de slag

Calculating the monthly mortgage payment

In order to make sure you can afford the home, you will have to calculate the monthly mortgage payment you will have to make on a loan that size.

Now, since you will be paying a monthly mortgage, you will have to convert each of the parameters into their monthly equivalents. Be careful when adjusting the interest rate, which is compounding!

In order to calculate the monthly mortgage payment, you will use the numpy function .pmt(rate, nper, pv) where:

  • rate = The periodic (monthly) interest rate
  • nper = The number of payment periods (months) in the lifespan of the mortgage loan
  • pv = The total value of the mortgage loan

You have been given a 30-year mortgage loan quote for your desired amount at 3.75%. The value of the mortgage loan is available as mortgage_loan.

The annual mortgage rate is available as mortgage_rate

Deze oefening maakt deel uit van de cursus

Introduction to Financial Concepts in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

import numpy as np

# Derive the equivalent monthly mortgage rate from the annual rate
mortgage_rate_periodic = ____

# How many monthly payment periods will there be over 30 years?
mortgage_payment_periods = ____

# Calculate the monthly mortgage payment (multiply by -1 to keep it positive)
periodic_mortgage_payment = -1*np.pmt(____, ____, ____)
print("Monthly Mortgage Payment: " + str(round(periodic_mortgage_payment, 2)))
Code bewerken en uitvoeren