rasmodev commited on
Commit
39e567c
Β·
verified Β·
1 Parent(s): d11b323

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Set the title of the app
4
+ st.set_page_config(page_title="Mortgage Calculator", page_icon="🏑", layout="centered")
5
+
6
+ # Add a header image
7
+ st.image("https://thumbs.dreamstime.com/b/d-house-budget-concept-render-56759583.jpg", use_column_width=True)
8
+
9
+ # Add a title and a subtitle
10
+ st.title("🏑 Mortgage Calculator")
11
+ st.write("Calculate your monthly payments and total cost of your mortgage with ease!")
12
+
13
+ # Customize with some styling
14
+ st.markdown("""
15
+ <style>
16
+ .main {
17
+ background-color: #f5f5f5;
18
+ }
19
+ h1 {
20
+ color: #FF6347;
21
+ }
22
+ .stButton button {
23
+ background-color: #4CAF50;
24
+ color: white;
25
+ border-radius: 8px;
26
+ font-size: 18px;
27
+ }
28
+ </style>
29
+ """, unsafe_allow_html=True)
30
+
31
+ # Request input for mortgage loan principal
32
+ principal = st.number_input("🏠 Enter the mortgage loan principal ($):", min_value=0.0, format="%.2f")
33
+
34
+ # Request input for the annual interest rate
35
+ interest_rate = st.number_input("πŸ’΅ Enter the annual interest rate (%):", min_value=0.0, format="%.2f")
36
+
37
+ # Request input for the number of years to repay the mortgage
38
+ years = st.number_input("⏳ Enter the number of years to repay the mortgage:", min_value=1, step=1)
39
+
40
+ # Add a calculate button
41
+ if st.button("Calculate"):
42
+ # Calculate the monthly repayment
43
+ monthly_repayment = principal * (interest_rate / 12 / 100 * (1 + interest_rate / 12 / 100)**(years * 12)) / \
44
+ ((1 + interest_rate / 12 / 100)**(years * 12) - 1)
45
+
46
+ # Calculate the total amount paid over the life of the mortgage
47
+ total_amount = monthly_repayment * years * 12
48
+
49
+ # Display the mortgage information to the user
50
+ st.success(f"For a {years}-year mortgage loan of $ {principal:,.2f}:")
51
+ st.write(f"at an annual interest rate of {interest_rate:.2f}%:")
52
+ st.write(f"πŸ’° **Monthly Payment**: $ {monthly_repayment:,.2f}")
53
+ st.write(f"πŸ’° **Total Payment**: $ {total_amount:,.2f}")
54
+
55
+ st.balloons()
56
+
57
+ # Add a footer
58
+ st.write("---")
59
+ st.write("πŸ’¬ *Thank you for using the Mortgage Calculator!*")