embed786 commited on
Commit
fb20b03
·
verified ·
1 Parent(s): bd221e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, step=1.0)
9
+ num2 = st.number_input("Enter second number", value=0.0, step=1.0)
10
+
11
+ # Operation selection
12
+ operation = st.selectbox("Choose an operation", ["Add", "Subtract", "Multiply", "Divide"])
13
+
14
+ # Calculate
15
+ if st.button("Calculate"):
16
+ if operation == "Add":
17
+ result = num1 + num2
18
+ st.success(f"Result: {result}")
19
+ elif operation == "Subtract":
20
+ result = num1 - num2
21
+ st.success(f"Result: {result}")
22
+ elif operation == "Multiply":
23
+ result = num1 * num2
24
+ st.success(f"Result: {result}")
25
+ elif operation == "Divide":
26
+ if num2 != 0:
27
+ result = num1 / num2
28
+ st.success(f"Result: {result}")
29
+ else:
30
+ st.error("Error: Division by zero!")