CoolFace
Apppublic

ahmad540/test_3

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py30 linesDownload Raw Back to root
1import streamlit as st2 3# Title of the application4st.title("Simple Calculator")5 6# User input for numbers7num1 = st.number_input("Enter first number", value=0.0, step=0.1)8num2 = st.number_input("Enter second number", value=0.0, step=0.1)9 10# Select operation11operation = st.selectbox("Choose an operation", ["Addition", "Subtraction", "Multiplication", "Division"])12 13# Perform calculation14result = None15if operation == "Addition":16    result = num1 + num217elif operation == "Subtraction":18    result = num1 - num219elif operation == "Multiplication":20    result = num1 * num221elif operation == "Division":22    if num2 != 0:23        result = num1 / num224    else:25        st.error("Error: Division by zero is not allowed.")26 27# Display the result28if result is not None:29    st.success(f"Result: {result}")30