faryalnimra commited on
Commit
0e1f72d
·
verified ·
1 Parent(s): 2d6e3bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("🧮 Simple Calculator")
4
+
5
+ # Input fields
6
+ num1 = st.number_input("Enter first number", value=0.0, format="%.2f")
7
+ num2 = st.number_input("Enter second number", value=0.0, format="%.2f")
8
+
9
+ # Operation selection
10
+ operation = st.selectbox("Choose operation", ["Add", "Subtract", "Multiply", "Divide"])
11
+
12
+ # Calculate button
13
+ if st.button("Calculate"):
14
+ if operation == "Add":
15
+ result = num1 + num2
16
+ elif operation == "Subtract":
17
+ result = num1 - num2
18
+ elif operation == "Multiply":
19
+ result = num1 * num2
20
+ elif operation == "Divide":
21
+ if num2 == 0:
22
+ result = "Error: Cannot divide by zero"
23
+ else:
24
+ result = num1 / num2
25
+ st.success(f"Result: {result}")