# Calculate monthly payment and rate of interest program in Tkinter

Last updated:6th Nov 2021

A bank wants to keep an inquiry page for inquiring about home loans. The rates of these loans are 7.8, 7.9, AND 9.8 for various spans of years (5/10/15) respectively. The user types the loan amount and selects the number of years for repayment of the loan (5/10/15) from the combo box. In return, the user gets information on the rate of loan, monthly installment for the specified number of years.

``````from tkinter import *
from tkinter import messagebox
from tkinter import ttk
def intrest():
p=int(e3.get())
n=int(e1.get())
r=find(n)/100
a=p*(1+r*n)
messagebox.showinfo("bill","monthly payment is "+str(a/(12*n))+"\nrate of intrest is"+str(r))
def find(n):
if(n==5):
return 7.8
elif(n==10):
return 7.9
elif(n==15):
return 9.8
def leave():
root.destroy()
root=Tk()
l1=Label(root,text="select no of years")
l1.grid(row=0,column=0)
l3=Label(root,text="enter principal amount")
l3.grid(row=1,column=0)
e1=ttk.Combobox(root,values=[5,10,15])
e1.grid(row=0,column=1)
e3=Entry(root)
e3.grid(row=1,column=1)
b1=Button(root,text="get monthly payment",command=intrest)
b1.grid(row=3,column=0)
b2=Button(root,text="quit",command=leave)
b2.grid(row=3,column=1)
root.mainloop()
``````

## output 