dadtechsol commited on
Commit
447de87
·
verified ·
1 Parent(s): 5ffda57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(page_title="Simple Calculator", page_icon="🧮")
4
+
5
+ st.title("🧮 Simple Calculator")
6
+
7
+ # Input fields
8
+ num1 = st.number_input("Enter first number", value=0.0, format="%.2f")
9
+ num2 = st.number_input("Enter second number", value=0.0, format="%.2f")
10
+
11
+ # Operation selection
12
+ operation = st.selectbox("Choose operation", ["Addition", "Subtraction", "Multiplication", "Division"])
13
+
14
+ # Calculate result
15
+ if st.button("Calculate"):
16
+ if operation == "Addition":
17
+ result = num1 + num2
18
+ elif operation == "Subtraction":
19
+ result = num1 - num2
20
+ elif operation == "Multiplication":
21
+ result = num1 * num2
22
+ elif operation == "Division":
23
+ if num2 != 0:
24
+ result = num1 / num2
25
+ else:
26
+ st.error("Division by zero is not allowed.")
27
+ result = None
28
+ else:
29
+ result = None
30
+
31
+ if result is not None:
32
+ st.success(f"Result: {result}")