Areebaaa commited on
Commit
1b7ac36
·
verified ·
1 Parent(s): 42004c7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # App title
4
+ st.title("🧮 Simple Calculator")
5
+
6
+ # Input fields
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 selector
11
+ operation = st.selectbox("Select operation", ["Add", "Subtract", "Multiply", "Divide"])
12
+
13
+ # Calculate and display result
14
+ if st.button("Calculate"):
15
+ if operation == "Add":
16
+ result = num1 + num2
17
+ elif operation == "Subtract":
18
+ result = num1 - num2
19
+ elif operation == "Multiply":
20
+ result = num1 * num2
21
+ elif operation == "Divide":
22
+ if num2 != 0:
23
+ result = num1 / num2
24
+ else:
25
+ result = "Error: Division by zero"
26
+
27
+ st.success(f"Result: {result}")