Home > Backend Development > Python Tutorial > Write a program to EMI calculator

Write a program to EMI calculator

Barbara Streisand
Release: 2024-11-23 13:25:16
Original
509 people have browsed it

Write a program to EMI calculator

EMI calculator:

An EMI Calculator helps you estimate your monthly installments easily. Once you enter the necessary details such as the loan amount, loan term, and interest rate, the bank's EMI calculator will instantly display your estimated Equated Monthly Installment (EMI).

To calculate your EMI, you can use the following formula:

EMI = [P x R x ( 1 R )^N] / [( 1 R )^N -1]

Where :

P = Principal Amount

R = Monthly Interest Rate (Annual Interest Rate / 12 months)

N = Loan Tenure in months

Example:

# Input the loan amount
loan = int(input("Enter the loan amount: "))

# Input the loan tenure in years and convert to months
tenure_year = int(input("Enter the loan tenure in years: "))
tenure_month = tenure_year * 12  # Convert years to months
print("Loan tenure in months:", tenure_month)

# Input the interest rate per year and convert to monthly interest rate
interest_year = float(input("Enter the interest per year: "))
interest_month = interest_year / 12 / 100  # Convert annual interest rate to monthly decimal rate
print("Interest per month in percentage:", interest_month)

# Calculate EMI using the formula
emi = loan * (interest_month * (1 + interest_month) ** tenure_month) / ((1 + interest_month) ** tenure_month - 1)

# Display the calculated EMI, rounded to 2 decimal places
print("EMI:", round(emi, 2))
Copy after login

Output:

Enter the loan amount:500000
Enter the loan tenure in years :10
Loan tenure in months: 120
Enter the interest per year:3.5
Interest per month in percentage: 0.002916666666666667
EMI: 4944.29


Copy after login

The above is the detailed content of Write a program to EMI calculator. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template