Calculating monthly repayment instalment for a loan using Python and numpy

Overview:

  • The pmt() function in numpy calculates the  monthly payment required for repaying a loan taken.
  • The repayment amount returned by the numpy.pmt() function is a sum consisting of both principal and interest parts.

 

Example:

import numpy as np

 

interestRate        = 0.0835;

numberOfMonths      = 240;

principalBorrowed   = 2000000;

monthlyPayment      = np.pmt(interestRate/12, numberOfMonths, principalBorrowed);

 

print("Principal Borrowed:%7.2f"%principalBorrowed);

print("Annual Interest Rate:%5.2f"%(interestRate*100));

print("Loan tenure in number of years:%d"%int(numberOfMonths/12));

print("Monthly Repayment to be made:%5.2f"%abs(monthlyPayment));

 

Output:

Principal Borrowed:2000000.00

Annual Interest Rate: 8.35

Loan tenure in number of years:20

Monthly Repayment to be made:17167.06

 


Copyright 2024 © pythontic.com