File size: 903 Bytes
42a3dbc 101d612 42a3dbc 101d612 42a3dbc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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)
# Streamlit App
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}")
|