EMI Calculator Using Python

EMI stands for Equated Monthly Installment, the EMI calculator is used to calculating the monthly installment of your loan amount. Normally compound interest is impounded on the monthly installments. The formula to calculate EMI is as follows

EMI = (P.r.(1+r)n) /((1+r)n-1)
where
P    - Principal amount
r    - The rate of interest
n    - time

EMI Calculator using Python

The source code for calculating EMI using python 3.6 is follows

#   program to find out EMI using formula
#   EMI  = (p*r(1+r)**t)/((1+r)**t-1)
#   made by     : rakesh kumar

from math import pow

def emi_calculate(p, r, t):
    r = r/(12*100)  # rate for one month
    t = t*12  # one month time
    emi = (p*r*pow(1+r, t))/(pow(1+r, t)-1)
    return emi


if __name__ == "__main__":
    p = int(input('Enter pricipal amount :'))
    r = int(input('Enter rate of interest :'))
    t = int(input('Enter time in years :'))
    emi = emi_calculate(p, r, t)

    print('Monthly Installment :%.2f' % emi)

The output is truncated up to two places of decimal using % String formating. The output of the EMI Calculator program

rakesh@folio MINGW64 /e/python (master)
$ python -u "e:\python\Loops\tempCodeRunnerFile.py"
Enter pricipal amount :1250000
Enter rate of interest :9
Enter time in years :10
Monthly Installment :15834.47

Send your queries via email.

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.