EMI calculator in Python
building an EMI calculator tool. Here's a Python code example to get you started:
# EMI Calculator Tool # Import math library import math # Define function to calculate EMI def calculate_emi(principal, interest_rate, years): # Convert interest rate from percentage to decimal interest_rate_decimal = interest_rate / 100 / 12 # Convert years to months months = years * 12 # Calculate EMI using formula emi = principal * interest_rate_decimal * math.pow(1 + interest_rate_decimal, months) / (math.pow(1 + interest_rate_decimal, months) - 1) # Return EMI return emi # Get input from user principal = float(input("Enter the loan amount: ")) interest_rate = float(input("Enter the interest rate (%): ")) years = int(input("Enter the number of years: ")) # Calculate EMI emi = calculate_emi(principal, interest_rate, years) # Print EMI print("EMI: ₹", round(emi, 2))
To use this tool, you can simply run the code in a Python environment or use an online Python compiler. When prompted, enter the loan amount, interest rate, and number of years, and the tool will calculate the EMI for you.
Note: This is a basic example and does not take into account factors such as prepayment, processing fees, or taxes. It is always advisable to consult with a financial advisor before making any financial decisions.