Home Loan Amortization Develop and test a Python program that calculates the mon
ID: 3867074 • Letter: H
Question
Home Loan Amortization Develop and test a Python program that calculates the monthly mortgage payments for a given loan amount, term (number of years) and range of interest rates from 3% to 18%. The fundamental formula for determining this is A/D, where A is the original loan amount, and D is the discount factor. The discount factor is calculated as, D = ((1 + r) ^n - 1)/r*(1 + r)^n where n is the number of total payments (12 times the number of years of the loan) and r is the interest rate, expressed in decimal form (e.g., 05), divided by 12. A monthly payment table should be generated as shown below, Loan Amount: $350, 000 Term: 30 years Interest Rate Monthly Payment 3% 1475.61 4% 1670.95 5% 1878.88 6% 209843 18% 5274.80 Which of the following lists are syntactically correct in Python and explain why?Explanation / Answer
LoanAmount = input("How much do you want to borrow? ")
interest = input("What is the interest rate on your loan? ")
term = input("How many years to repay your loan? ")
LoanAmount = float(LoanAmount)
interest = float(interest)
term = float(term)
import math
def loan_mortgage(LoanAmount, interest, term):
'''
given mortgage loan Amount, interestRate(%) and years to pay
calculated and returned the monthly payment amount
'''
# monthly rate from annual percentage rate
interest_rate = interest/(100 * 12)
# total number of payments
payment_num = term * 12
#Calculate the Discount Factor
DiscountFactor = (math.pow((1+interest_rate),(payment_num-1))/interest_rate * (math.pow((1+interest_rate),(payment_num))
# calculate monthly payment
payment = LoanAmount/DiscountFactor;
return payment
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.