# Read the amount borrowed, interest rate and loan duration from the user. amount = float(input("Enter the loan amount: ")) rate = float(input("Enter the interest rate (5 for 5%): ")) years = float(input("Enter the loan duration in years: ")) # Convert the rate from annual to per payment period rate = rate / 100 / 12 num_payments = years * 12 # Compute the payment amount. payment = (rate * amount) / (1 - (1 + rate) ** -num_payments) # Compute the cost of borrowing. cost_of_borrowing = payment * num_payments - amount # Display the results. print("The loan payment amount per month is", payment) print("The total cost of borrowing is", cost_of_borrowing)