calculator
To upload files, please first save the app
import streamlit as st
st.title("Simple Calculator")
# Create two columns for input
col1, col2 = st.columns(2)
with col1:
num1 = st.number_input("Enter first number", value=0.0)
with col2:
num2 = st.number_input("Enter second number", value=0.0)
# Create operation selection
operation = st.selectbox(
"Select operation",
("Addition", "Subtraction", "Multiplication", "Division")
)
# Calculate result
if st.button("Calculate"):
if operation == "Addition":
result = num1 + num2
st.success(f"{num1} + {num2} = {result}")
elif operation == "Subtraction":
result = num1 - num2
st.success(f"{num1} - {num2} = {result}")
elif operation == "Multiplication":
result = num1 * num2
st.success(f"{num1} × {num2} = {result}")
elif operation == "Division":
if num2 != 0:
result = num1 / num2
st.success(f"{num1} ÷ {num2} = {result}")
else:
st.error("Error: Division by zero!")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?