AamerAkhter commited on
Commit
7fbf41d
·
verified ·
1 Parent(s): cea098e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title of the app
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
+ # Operator selection
11
+ operation = st.selectbox("Select operation", ["Addition (+)", "Subtraction (-)", "Multiplication (*)", "Division (/)"])
12
+
13
+ # Perform calculation
14
+ result = None
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
+ result = num1 / num2
25
+ else:
26
+ st.error("Division by zero is not allowed.")
27
+
28
+ if result is not None:
29
+ st.success(f"Result: {result}")