Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a python function called calcMonthlyPmt that accepts THREE parameters (

ID: 3802325 • Letter: 1

Question

1. Write a python function called calcMonthlyPmt that accepts THREE parameters (interest rate, loan amount and number of years) and should return the monthly payment.

Use this formula to calculate the monthly payment: ratePerMonth * loanAmount

1 – (1 + ratePerMonth) –numMonths

NOTE: there should be NO input or print statements in this function!

2. Write another function called calcTotalPmts. It should accept TWO parameters (monthlyPmt and number of months) and should return the total amount paid for the loan. NOTE: there should be NO input or print statements in this function!

3. In the main program, ask the user to enter these values at the beginning of the program.

• Loan amount

• Loan period (# of years)

Use a loop to display the results using a series of different interest rates.The loop should allow the interest rate to range from 5% up to and including 8%.Increment the interest rate by 1/8 each time through the loop. Each time through your loop, you should call your two functions to calculate the monthly and total payments, and print a line that displays these 3 values:

• Interest Rate (formatted to display exactly 3 digits to the right of the decimal)

• Monthly payment (formatted to display exactly 2 digits to the right of the decimal)

• Total payment (formatted to display exactly 2 digits to the right of the decimal) Remember to include headings AND the underlining beneath the headings. Here is a sample run:

Explanation / Answer

Python code:

print "Enter the Loan Amount!"
P = float(raw_input().strip())
print "Enter the number of years!"
y = int(raw_input().strip())
N = 12*y
annualrate = 5.0
while(annualrate <= 8):
   R = annualrate/(100*12)
   EMI = (P * R * ((1+R)**N) )/((1+R)**N-1)
   print "Interest Rate = ", round(annualrate,3),
   print "Monthly payment = ", round(EMI,2),
   print "Total payment = ", round(N*EMI, 2)
   annualrate = annualrate + 0.125

Sample Output:

Enter the Loan Amount!
500000
Enter the number of years!
2
Interest Rate = 5.0 Monthly payment = 21935.69 Total payment = 526456.68
Interest Rate = 5.125 Monthly payment = 21963.7 Total payment = 527128.7
Interest Rate = 5.25 Monthly payment = 21991.72 Total payment = 527801.24
Interest Rate = 5.375 Monthly payment = 22019.76 Total payment = 528474.3
Interest Rate = 5.5 Monthly payment = 22047.83 Total payment = 529147.87
Interest Rate = 5.625 Monthly payment = 22075.92 Total payment = 529821.96
Interest Rate = 5.75 Monthly payment = 22104.02 Total payment = 530496.57
Interest Rate = 5.875 Monthly payment = 22132.15 Total payment = 531171.69
Interest Rate = 6.0 Monthly payment = 22160.31 Total payment = 531847.32
Interest Rate = 6.125 Monthly payment = 22188.48 Total payment = 532523.47
Interest Rate = 6.25 Monthly payment = 22216.67 Total payment = 533200.14
Interest Rate = 6.375 Monthly payment = 22244.89 Total payment = 533877.32
Interest Rate = 6.5 Monthly payment = 22273.13 Total payment = 534555.02
Interest Rate = 6.625 Monthly payment = 22301.38 Total payment = 535233.23
Interest Rate = 6.75 Monthly payment = 22329.66 Total payment = 535911.95
Interest Rate = 6.875 Monthly payment = 22357.97 Total payment = 536591.19
Interest Rate = 7.0 Monthly payment = 22386.29 Total payment = 537270.95
Interest Rate = 7.125 Monthly payment = 22414.63 Total payment = 537951.22
Interest Rate = 7.25 Monthly payment = 22443.0 Total payment = 538632.0
Interest Rate = 7.375 Monthly payment = 22471.39 Total payment = 539313.3
Interest Rate = 7.5 Monthly payment = 22499.8 Total payment = 539995.11
Interest Rate = 7.625 Monthly payment = 22528.23 Total payment = 540677.44
Interest Rate = 7.75 Monthly payment = 22556.68 Total payment = 541360.28
Interest Rate = 7.875 Monthly payment = 22585.15 Total payment = 542043.63
Interest Rate = 8.0 Monthly payment = 22613.65 Total payment = 542727.5