Spaces:
Sleeping
Sleeping
import streamlit as st | |
st.title("Calculator") | |
col1, col2, col3 = st.columns(3) | |
with col1: | |
a = st.number_input("First number", value=1.0) | |
with col2: | |
b = st.number_input("Second number", value=2.0) | |
with col3: | |
operation = st.selectbox("Choose the operation", ["+", "-", "*", "/"]) | |
if operation == "+": | |
st.write(a, "+", b, "=", a + b) | |
elif operation == "-": | |
st.write(a, "-", b, "=", a - b) | |
elif operation == "*": | |
st.write(a, "*", b, "=", a * b) | |
elif operation == "/": | |
if b == 0: | |
st.warning("Divided by zero") | |
else: | |
st.write(a, "/", b, "=", a / b) | |