# # Compute the payment amount and cost of borrowing for a car loan. # # Read the input from the user: The amount being borrowed, the interest rate, # duration of the loan. 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 input values into the form expected for the payment formula. num_payments = years * 12 rate = rate / 100 / 12 # Compute the payment amount. payment = rate * amount / (1 - (1 + rate) ** -num_payments) # Compute the cost of borrowing. cost = payment * num_payments - amount # Display the results. print(f"The payment amount is ${payment:,.2f}") print(f"The cost of borrowing is ${cost:,.2f}")