Start New Discussion within our **Software Development Community** # Loan calculation using Python module numpy

```
''' np_payments.py
calculate periodic payments on a given bank loan using module numpy
numpy.pmt(periodic_rate, period_number, loan_value, fv=0, when='end')
module numpy (numeric python extensions, high speed)
download free from: http://sourceforge.net/projects/numpy
I used numpy Windows installers
numpy-MKL-1.7.1.win32-py2.7.exe
and/or
numpy-MKL-1.7.1.win32-py3.3.exe
from
http://www.lfd.uci.edu/~gohlke/pythonlibs/
for docs see:
http://wiki.scipy.org/Numpy_Example_List_With_Doc
tested with Python27 and Python33 by vegaseat 22oct2013
'''
import numpy as np
# assume annual interest of 7.5%
interest = 7.5
annual_rate = interest/100.0
monthly_rate = annual_rate/12
# assume payment over 15 years
years = 15
number_month = years * 12
# assume a loan value of $200,000
loan_value = 200000
monthly_payment = abs(np.pmt(monthly_rate, number_month, loan_value))
sf1 = "Paying off a loan of ${:,} over {} years at"
sf2 = "{}% interest, your monthly payment will be ${:,.2f}"
print(sf1.format(loan_value, years))
print(sf2.format(interest, monthly_payment))
''' result ...
Paying off a loan of $200,000 over 15 years at
7.5% interest, your monthly payment will be $1,854.02
'''
```

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.