Minds commited on
Commit
2de7eab
·
verified ·
1 Parent(s): 5b4996f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def calculator():
4
+ st.title("Simple Calculator")
5
+
6
+ num1 = st.number_input("Enter first number", format="%.5f")
7
+ num2 = st.number_input("Enter second number", format="%.5f")
8
+ operation = st.selectbox("Choose operation", ["Addition", "Subtraction", "Multiplication", "Division"])
9
+
10
+ if st.button("Calculate"):
11
+ if operation == "Addition":
12
+ result = num1 + num2
13
+ st.success(f"Result: {result}")
14
+ elif operation == "Subtraction":
15
+ result = num1 - num2
16
+ st.success(f"Result: {result}")
17
+ elif operation == "Multiplication":
18
+ result = num1 * num2
19
+ st.success(f"Result: {result}")
20
+ elif operation == "Division":
21
+ if num2 == 0:
22
+ st.error("Cannot divide by zero!")
23
+ else:
24
+ result = num1 / num2
25
+ st.success(f"Result: {result}")
26
+
27
+ if __name__ == "__main__":
28
+ calculator()