|
|
import streamlit as st
|
|
|
|
|
|
st.title("Simple Calculator")
|
|
|
|
|
|
|
|
|
num1 = st.number_input("Enter first number", format="%.2f")
|
|
|
num2 = st.number_input("Enter second number", format="%.2f")
|
|
|
|
|
|
|
|
|
operation = st.selectbox("Select operation", ["+", "-", "*", "/"])
|
|
|
|
|
|
|
|
|
if st.button("Calculate"):
|
|
|
if operation == "+":
|
|
|
result = num1 + num2
|
|
|
st.success(f"The result is: {result}")
|
|
|
elif operation == "-":
|
|
|
result = num1 - num2
|
|
|
st.success(f"The result is: {result}")
|
|
|
elif operation == "*":
|
|
|
result = num1 * num2
|
|
|
st.success(f"The result is: {result}")
|
|
|
elif operation == "/":
|
|
|
if num2 != 0:
|
|
|
result = num1 / num2
|
|
|
st.success(f"The result is: {result}")
|
|
|
else:
|
|
|
st.error("Cannot divide by zero!")
|
|
|
|