-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (26 loc) · 895 Bytes
/
app.py
File metadata and controls
32 lines (26 loc) · 895 Bytes
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
32
import streamlit as st
st.set_page_config(page_title="Калькулятор", page_icon="🧮")
st.title("🧮 Крутой калькулятор")
st.write("Сделано на Python + Streamlit 😎")
a = st.number_input("Первое число", value=0.0)
b = st.number_input("Второе число", value=0.0)
op = st.selectbox("Операция", ["+", "-", "*", "/", "**", "%"])
if st.button("Вычислить"):
if op == "+":
result = a + b
elif op == "-":
result = a - b
elif op == "*":
result = a * b
elif op == "/":
if b == 0:
st.error("На ноль делить нельзя 🚫")
result = None
else:
result = a / b
elif op == "**":
result = a ** b
elif op == "%":
result = a % b
if result is not None:
st.success(f"Ответ: {result}")