CoolFace
Apppublic

Nizamali012/Time_value_Calculation

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
app.py73 linesDownload Raw Back to root
1import streamlit as st2import numpy as np3 4st.set_page_config(page_title="Chemical Engineering TVM Calculator")5 6st.title("๐Ÿ’ฐ Time Value of Money - Chemical Engineering App")7 8st.markdown("This app helps evaluate engineering projects using financial concepts like PV, FV, and NPV.")9 10# Sidebar options11option = st.sidebar.selectbox(12    "Choose Calculation",13    ("Future Value (FV)", "Present Value (PV)", "Net Present Value (NPV)")14)15 16# -----------------------------17# Future Value Calculation18# -----------------------------19if option == "Future Value (FV)":20    st.header("Future Value (FV)")21 22    PV = st.number_input("Present Value (Initial Investment)", value=1000.0)23    r = st.number_input("Interest Rate (%)", value=10.0)24    n = st.number_input("Time (years)", value=5)25 26    FV = PV * (1 + r/100)**n27 28    st.success(f"Future Value = {FV:.2f}")29 30# -----------------------------31# Present Value Calculation32# -----------------------------33elif option == "Present Value (PV)":34    st.header("Present Value (PV)")35 36    FV = st.number_input("Future Value", value=2000.0)37    r = st.number_input("Discount Rate (%)", value=10.0)38    n = st.number_input("Time (years)", value=5)39 40    PV = FV / (1 + r/100)**n41 42    st.success(f"Present Value = {PV:.2f}")43 44# -----------------------------45# Net Present Value (NPV)46# -----------------------------47elif option == "Net Present Value (NPV)":48    st.header("Net Present Value (NPV) - Chemical Engineering Project")49 50    st.markdown("Enter cash flows for each year (typical for plant projects).")51 52    discount_rate = st.number_input("Discount Rate (%)", value=10.0)53 54    years = st.number_input("Number of Years", min_value=1, max_value=20, value=5)55 56    cash_flows = []57 58    for i in range(years):59        cf = st.number_input(f"Cash Flow Year {i+1}", value=1000.0, key=i)60        cash_flows.append(cf)61 62    initial_investment = st.number_input("Initial Investment (negative)", value=-5000.0)63 64    npv = initial_investment65    for t, cf in enumerate(cash_flows):66        npv += cf / (1 + discount_rate/100)**(t+1)67 68    st.success(f"NPV = {npv:.2f}")69 70    if npv > 0:71        st.info("โœ… Project is PROFITABLE")72    else:73        st.warning("โŒ Project is NOT profitable")