Spaces:
Runtime error

charan / app.py
Reddy2909's picture
Create app.py
436aa07 verified
Raw History Blame Contribute Delete
677 Bytes
import streamlit as st
# Title of the app
st.title("Simple Calculator")
# Input numbers
num1 = st.number_input("Enter first number", value=0.0)
num2 = st.number_input("Enter second number", value=0.0)
# Operation selection
operation = st.selectbox("Select operation", ["Add", "Subtract", "Multiply", "Divide"])
# Perform the calculation
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! Division by zero."
# Display the result
st.write("Result:", result)