Team Ai
Apppublic

Java1234/simple_arithmethic

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py31 linesDownload Raw Back to root
1# app.py2import streamlit as st3 4def main():5    st.title("Simple Calculator")6    7    num1 = st.number_input("Enter first number", value=0.0)8    num2 = st.number_input("Enter second number", value=0.0)9    10    operation = st.selectbox("Choose operation", ["Addition", "Subtraction", "Multiplication", "Division"])11    12    result = None13    if st.button("Calculate"):14        if operation == "Addition":15            result = num1 + num216        elif operation == "Subtraction":17            result = num1 - num218        elif operation == "Multiplication":19            result = num1 * num220        elif operation == "Division":21            if num2 != 0:22                result = num1 / num223            else:24                st.error("Cannot divide by zero")25        26        if result is not None:27            st.success(f"Result: {result}")28 29if __name__ == "__main__":30    main()31