-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (21 loc) · 919 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
import streamlit as sl
sl.title('Inflation Calculator')
form = sl.form('calculator_form')
initial_amount = form.number_input('Enter initial amount', value=10000)
inflation_rate = form.number_input('Annual inflation rate (%)', value=7.0)
years = form.number_input('Number of years', value=10)
submit = form.form_submit_button('Calculate')
def calculate_inflation(initial_amount, inflation_rate, years):
return initial_amount * (1 + inflation_rate / 100) ** years
if submit:
future_value = calculate_inflation(initial_amount, inflation_rate, years)
sl.write("Future value: ", future_value)
year_range = range(0, years + 1)
future_values = [calculate_inflation(
initial_amount, inflation_rate, year) for year in year_range]
data = pd.DataFrame({
'Year': year_range,
'Future Value': future_values
})
sl.line_chart(data.set_index('Year'))