SarmadRasool commited on
Commit
67c293f
·
verified ·
1 Parent(s): 23d9fcb

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +30 -0
App.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Streamlit UI
4
+ st.title("Simple Calculator")
5
+ st.write("Perform basic arithmetic operations")
6
+
7
+ # User inputs
8
+ num1 = st.number_input("Enter first number", value=0.0, format="%.2f")
9
+ num2 = st.number_input("Enter second number", value=0.0, format="%.2f")
10
+ operation = st.selectbox("Select Operation", ["Addition", "Subtraction", "Multiplication", "Division"])
11
+
12
+ # Perform Calculation
13
+ result = None
14
+
15
+ if st.button("Calculate"):
16
+ if operation == "Addition":
17
+ result = num1 + num2
18
+ elif operation == "Subtraction":
19
+ result = num1 - num2
20
+ elif operation == "Multiplication":
21
+ result = num1 * num2
22
+ elif operation == "Division":
23
+ if num2 == 0:
24
+ st.error("Cannot divide by zero!")
25
+ else:
26
+ result = num1 / num2
27
+
28
+ # Display Result
29
+ if result is not None:
30
+ st.success(f"Result: {result}")