GALOLIT commited on
Commit
2f3728d
1 Parent(s): 9d91648

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+
5
+
6
+ # Streamlit app layout
7
+
8
+ st.title("Savings account interest 💼")
9
+
10
+ def calcular_cashflow(n, A, r, Pi):
11
+ cashflow = []
12
+ saldo = Pi
13
+ for i in range(n):
14
+ interes = saldo * (r/100)
15
+ abono_capital = A - interes
16
+ saldo += abono_capital
17
+ cashflow.append(saldo)
18
+ return cashflow
19
+
20
+ def graficar_cashflow(cashflow):
21
+ meses = range(1, len(cashflow) + 1)
22
+ fig, ax = plt.subplots()
23
+ ax.plot(meses, cashflow, marker='o', linestyle='-')
24
+ ax.set_title('Cashflow por Mensualidad')
25
+ ax.set_xlabel('Mes')
26
+ ax.set_ylabel('Saldo')
27
+ ax.grid(True)
28
+ return fig, ax
29
+
30
+ def main():
31
+
32
+ n = st.number_input("Ingrese el número de mensualidades:", min_value=1, step=1, format='%d')
33
+ A = st.number_input("Ingrese el monto de la mensualidad:", min_value=0.0, step=1.0, format='%f')
34
+ r = st.number_input("Ingrese la tasa de interés (%):", min_value=0.0, step=0.01, format='%f')
35
+ Pi = st.number_input("Ingrese el depósito inicial:", min_value=0.0, step=1.0, format='%f')
36
+
37
+ if st.button('Calcular y Graficar Cashflow'):
38
+ cashflow = calcular_cashflow(int(n), float(A), float(r), float(Pi))
39
+ fig, ax = graficar_cashflow(cashflow)
40
+ st.pyplot(fig)
41
+
42
+ if _name_ == "_main_":
43
+     main()