Spaces:
Runtime error
Runtime error
Commit
•
a6f8c81
1
Parent(s):
0402749
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
|
4 |
+
def calcular_cashflow(n, A, r, Pi):
|
5 |
+
cashflow = []
|
6 |
+
saldo = Pi
|
7 |
+
for i in range(n):
|
8 |
+
interes = saldo * (r/100)
|
9 |
+
abono_capital = A - interes
|
10 |
+
saldo += abono_capital
|
11 |
+
cashflow.append(saldo)
|
12 |
+
return cashflow
|
13 |
+
|
14 |
+
def graficar_cashflow(cashflow):
|
15 |
+
meses = range(1, len(cashflow) + 1)
|
16 |
+
plt.plot(meses, cashflow, marker='o', linestyle='-')
|
17 |
+
plt.title('Cashflow por Mensualidad')
|
18 |
+
plt.xlabel('Mes')
|
19 |
+
plt.ylabel('Saldo')
|
20 |
+
plt.grid(True)
|
21 |
+
plt.show()
|
22 |
+
|
23 |
+
def main():
|
24 |
+
n = int(input("Ingrese el número de mensualidades: "))
|
25 |
+
A = float(input("Ingrese el monto de la mensualidad: "))
|
26 |
+
r = float(input("Ingrese la tasa de interés (%): "))
|
27 |
+
Pi = float(input("Ingrese el depósito inicial: "))
|
28 |
+
|
29 |
+
cashflow = calcular_cashflow(n, A, r, Pi)
|
30 |
+
graficar_cashflow(cashflow)
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
main()
|