shivrajkarewar commited on
Commit
42a3dbc
·
verified ·
1 Parent(s): 8e4d552

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -17
app.py CHANGED
@@ -1,27 +1,22 @@
 
1
 
2
  def loan_emi(amount, duration, rate, down_payment=0):
3
  """
4
  Calculate the Equated Monthly Installment (EMI) for a loan.
5
-
6
- Parameters:
7
- amount (float): Total loan amount (principal).
8
- duration (int): Loan duration in months.
9
- rate (float): Monthly interest rate (as a decimal, e.g., 0.1 for 10%).
10
- down_payment (float, optional): Initial amount paid upfront. Default is 0.
11
-
12
- Returns:
13
- float: EMI amount rounded to 2 decimal places.
14
  """
15
  loan_amount = amount - down_payment
16
  emi = (loan_amount * rate * ((1 + rate) ** duration)) / (((1 + rate) ** duration) - 1)
17
  return round(emi, 2)
18
 
19
- # Example usage
20
- if __name__ == "__main__":
21
- amount = float(input("Enter the loan amount: ")) # Principal amount
22
- duration = int(input("Enter the loan duration in months: ")) # Loan duration in months
23
- rate = float(input("Enter the monthly interest rate (as decimal, e.g., 0.1 for 10%): ")) # Monthly interest rate
24
- down_payment = float(input("Enter the down payment amount (if any, else 0): "))
25
-
 
 
26
  emi_value = loan_emi(amount, duration, rate, down_payment)
27
- print(f"Monthly EMI: {emi_value}")
 
 
1
+ import streamlit as st
2
 
3
  def loan_emi(amount, duration, rate, down_payment=0):
4
  """
5
  Calculate the Equated Monthly Installment (EMI) for a loan.
 
 
 
 
 
 
 
 
 
6
  """
7
  loan_amount = amount - down_payment
8
  emi = (loan_amount * rate * ((1 + rate) ** duration)) / (((1 + rate) ** duration) - 1)
9
  return round(emi, 2)
10
 
11
+ # Streamlit App
12
+ st.title("EMI Calculator")
13
+
14
+ amount = st.number_input("Enter the loan amount:", min_value=0.0, format="%f")
15
+ duration = st.number_input("Enter the loan duration in months:", min_value=1, format="%d")
16
+ rate = st.number_input("Enter the monthly interest rate (as decimal, e.g., 0.1 for 10%):", min_value=0.0, format="%f")
17
+ down_payment = st.number_input("Enter the down payment amount (if any, else 0):", min_value=0.0, format="%f")
18
+
19
+ if st.button("Calculate EMI"):
20
  emi_value = loan_emi(amount, duration, rate, down_payment)
21
+ st.success(f"Your Monthly EMI: {emi_value}")
22
+