zealouszohaib commited on
Commit
9f8aaf3
·
verified ·
1 Parent(s): 67e9dfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+
5
+ st.title("🧮 Simple Calculator")
6
+
7
+ # User inputs
8
+ num1 = st.number_input("Enter first number", format="%.2f")
9
+ num2 = st.number_input("Enter second number", format="%.2f")
10
+ operation = st.selectbox("Choose operation", ["Add", "Subtract", "Multiply", "Divide"])
11
+
12
+ # Perform calculation
13
+ result = None
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 = num1 / num2
23
+ else:
24
+ st.error("Cannot divide by zero!")
25
+
26
+ # Show result
27
+ if result is not None:
28
+ st.success(f"Result: {result}")