|
import streamlit as st |
|
|
|
def loan_emi(amount, duration, rate, down_payment=0): |
|
""" |
|
Calculate the Equated Monthly Installment (EMI) for a loan. |
|
""" |
|
loan_amount = amount - down_payment |
|
emi = (loan_amount * rate * ((1 + rate) ** duration)) / (((1 + rate) ** duration) - 1) |
|
return round(emi, 2) |
|
|
|
|
|
st.title("EMI Calculator") |
|
|
|
amount = st.number_input("Enter the loan amount:", min_value=0.0, format="%f") |
|
duration = st.number_input("Enter the loan duration in months:", min_value=1, format="%d") |
|
rate = st.number_input("Enter the monthly interest rate (as decimal, e.g., 0.1 for 10%):", min_value=0.0, format="%f") |
|
down_payment = st.number_input("Enter the down payment amount (if any, else 0):", min_value=0.0, format="%f") |
|
|
|
if st.button("Calculate EMI"): |
|
emi_value = loan_emi(amount, duration, rate, down_payment) |
|
st.success(f"Your Monthly EMI: {emi_value}") |
|
|
|
|