File size: 593 Bytes
7f1610a
 
854eb71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)