def emi_calculator(principal, interest_rate, num_years): num_payments = num_years * 12 # total number of monthly payments monthly_interest_rate = interest_rate / (12 * 100) # monthly interest rate emi = (principal * monthly_interest_rate) / (1 - (1 + monthly_interest_rate) ** (-num_payments)) return emi # Example usage: principal = 100000 # loan amount interest_rate = 8.5 # annual interest rate num_years = 5 # loan term in years emi = emi_calculator(principal, interest_rate, num_years) print(f"EMI: {emi:.2f}")