# Compute the payment amount and total cost of borrowing for a car loan from # the amount borrowed, interest rate and loan duration entered by the user. # 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 = int(input("Enter the loan duration in years: ")) # Convert the interest rate from a percentage into a decimal, and from an # annual rate to the rate per payment period rate = rate / 100 / 12 # Compute the number of payments num_payments = years * 12 # Compute the payment amount payment = (rate * amount) / (1 - (1 + rate) ** -num_payments) # Compute the total cost of borrowing cost = num_payments * payment - amount # Display the results formatted to 2 decimal places print("Your monthly payment will be: $%.2f." % payment) print("The total cost of borrowing is: $%.2f." % cost)