# A program that computes the payment amount for a loan, along with the # total cost of borrowing, from the amount borrowed, interest rate and # duration entered by the user. # Read the amount borrowed, interest rate and loan duration from the user amt = float(input("Enter the loan amount: ")) rate = float(input("Enter the interest rate (5 for 5%): ")) years = int(input("How many years will it take to repay the loan? ")) # Convert the interest rate from annual to rate per payment period rate = rate / 12 / 100 # Compute the number of payments num_payments = years * 12 # Compute the payment amount payment = rate * amt / (1 - (1 + rate) ** -num_payments) # Compute the total cost of borrowing total_cost = num_payments * payment - amt # Display the results print("The payment amount will be %.2f" % payment) print("The total cost of borrowing will be %.2f" % total_cost)