MuhammadSajid commited on
Commit
c87ffd4
·
verified ·
1 Parent(s): 746bc04

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
7
+ num2 = st.number_input("Enter second number", value=0.0)
8
+
9
+ # Operation selection
10
+ operation = st.selectbox("Select Operation", ["Addition (+)", "Subtraction (-)", "Multiplication (×)", "Division (÷)"])
11
+
12
+ # Calculate result
13
+ if st.button("Calculate"):
14
+ if operation == "Addition (+)":
15
+ result = num1 + num2
16
+ st.success(f"Result: {result}")
17
+ elif operation == "Subtraction (-)":
18
+ result = num1 - num2
19
+ st.success(f"Result: {result}")
20
+ elif operation == "Multiplication (×)":
21
+ result = num1 * num2
22
+ st.success(f"Result: {result}")
23
+ elif operation == "Division (÷)":
24
+ if num2 != 0:
25
+ result = num1 / num2
26
+ st.success(f"Result: {result}")
27
+ else:
28
+ st.error("Error: Cannot divide by zero")