Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| # Function to calculate salaries and differences | |
| def calculate_lifestyle_cost(current_salary, expected_salary, growth_rate, years): | |
| current_salary_yearly = [] | |
| expected_salary_yearly = [] | |
| difference_yearly = [] | |
| for year in range(1, years + 1): | |
| current_salary_yearly.append(current_salary) | |
| expected_salary_yearly.append(expected_salary) | |
| difference_yearly.append(expected_salary - current_salary) | |
| current_salary *= (1 + growth_rate) | |
| expected_salary *= (1 + growth_rate) | |
| cumulative_difference = sum(difference_yearly) | |
| data = { | |
| "Year": list(range(1, years + 1)), | |
| "Current Salary (INR)": [int(x) for x in current_salary_yearly], | |
| "Expected Salary (INR)": [int(x) for x in expected_salary_yearly], | |
| "Difference (INR)": [int(x) for x in difference_yearly], | |
| } | |
| return pd.DataFrame(data), int(cumulative_difference) | |
| # Streamlit UI | |
| st.title("Cost of Delayed Lifestyle Calculator") | |
| st.write( | |
| "### How many months/years are willing to delay your Lifestyle?" | |
| ) | |
| # Sidebar inputs | |
| st.sidebar.header("Enter Current and Future Salary") | |
| current_salary = st.sidebar.number_input( | |
| "Enter your current salary (INR):", min_value=0, value=1500000, step=10000 | |
| ) | |
| expected_salary = st.sidebar.number_input( | |
| "Enter your expected/deserved salary (INR):", min_value=0, value=2500000, step=10000 | |
| ) | |
| growth_rate = st.sidebar.slider("Annual salary growth rate (%):", min_value=0, max_value=20, value=8) / 100 | |
| years = st.sidebar.slider("Number of years:", min_value=1, max_value=20, value=10) | |
| # Calculate and display results | |
| if st.sidebar.button("Calculate"): | |
| result_df, cumulative_difference = calculate_lifestyle_cost( | |
| current_salary, expected_salary, growth_rate, years | |
| ) | |
| st.write( | |
| f"### Cumulative Cost of Delayed Lifestyle Over {years} Years:" | |
| ) | |
| st.write( | |
| f"# INR {cumulative_difference:,.0f}" | |
| ) | |
| st.dataframe(result_df.style.format(precision=0)) # Remove decimals from display | |