Make a calculator app
To upload files, please first save the app
import streamlit as st
st.title("Simple Calculator")
# Input fields for two numbers
num1 = st.number_input("Enter first number:")
num2 = st.number_input("Enter second number:")
# Dropdown for operation selection
operation = st.selectbox("Select operation:", ["Add", "Subtract", "Multiply", "Divide"])
# Calculation based on the selected operation
if st.button("Calculate"):
if operation == "Add":
result = num1 + num2
elif operation == "Subtract":
result = num1 - num2
elif operation == "Multiply":
result = num1 * num2
elif operation == "Divide":
if num2 != 0:
result = num1 / num2
else:
result = "Error: Cannot divide by zero"
st.write("Result: ", result)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?