Hikmatk commited on
Commit
1edeb4e
·
verified ·
1 Parent(s): def05b3

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
+ # Perform calculation
13
+ result = None
14
+ if st.button("Calculate"):
15
+ if operation == "Addition (+)":
16
+ result = num1 + num2
17
+ elif operation == "Subtraction (-)":
18
+ result = num1 - num2
19
+ elif operation == "Multiplication (*)":
20
+ result = num1 * num2
21
+ elif operation == "Division (/)":
22
+ if num2 != 0:
23
+ result = num1 / num2
24
+ else:
25
+ st.error("Division by zero is not allowed.")
26
+
27
+ if result is not None:
28
+ st.success(f"Result: {result}")