Spaces:
Build error
Build error
File size: 772 Bytes
b7bcd93 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # app.py
import streamlit as st
# Title of the app
st.title("\U0001F9EE Simple Calculator App")
# User inputs
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("Choose an operation", ["Add", "Subtract", "Multiply", "Divide"])
# Perform calculation
def calculate(n1, n2, op):
if op == "Add":
return n1 + n2
elif op == "Subtract":
return n1 - n2
elif op == "Multiply":
return n1 * n2
elif op == "Divide":
if n2 == 0:
return "Error: Division by zero"
return n1 / n2
# Display result
if st.button("Calculate"):
result = calculate(num1, num2, operation)
st.success(f"Result: {result}")
|