manaskhan commited on
Commit
04f48b5
·
verified ·
1 Parent(s): f16aa2e

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
+ # Title
4
+ st.title("🔢 Simple Calculator")
5
+
6
+ # User input
7
+ num1 = st.number_input("Enter first number:", value=0.0)
8
+ num2 = st.number_input("Enter second number:", value=0.0)
9
+
10
+ # Operation selection
11
+ operation = st.selectbox("Choose an operation:", ["Add", "Subtract", "Multiply", "Divide"])
12
+
13
+ # Calculate result
14
+ result = None
15
+ if st.button("Calculate"):
16
+ if operation == "Add":
17
+ result = num1 + num2
18
+ elif operation == "Subtract":
19
+ result = num1 - num2
20
+ elif operation == "Multiply":
21
+ result = num1 * num2
22
+ elif operation == "Divide":
23
+ if num2 != 0:
24
+ result = num1 / num2
25
+ else:
26
+ st.error("Division by zero is not allowed!")
27
+
28
+ # Show result
29
+ if result is not None:
30
+ st.success(f"Result: {result}")