calculator
To upload files, please first save the app
import streamlit as st
st.title("Simple Calculator")
# Function to calculate the results
def calculate(num1, num2, operator):
if operator == " + ":
return num1 + num2
elif operator == " - ":
return num1 - num2
elif operator == " * ":
return num1 * num2
elif operator == " / ":
return num1 / num2
else:
return "Invalid operator"
# Input fields for the numbers and operator
num1 = st.number_input("Enter first number:", value=0)
num2 = st.number_input("Enter second number:", value=0)
operator = st.selectbox("Select an operator:", options=[" + ", " - ", " * ", " / "])
# Calculate and display the result
result = calculate(num1, num2, operator)
st.write(f"Result: {result}")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?