BQGamer commited on
Commit
14dbf7a
·
verified ·
1 Parent(s): 5015e09

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title of the application
4
+ st.title('Basic Calculator')
5
+
6
+ # Sidebar for calculator operations
7
+ operation = st.sidebar.selectbox(
8
+ "Choose operation",
9
+ ("Add", "Subtract", "Multiply", "Divide")
10
+ )
11
+
12
+ # User input for two numbers
13
+ num1 = st.number_input('Enter first number', value=0)
14
+ num2 = st.number_input('Enter second number', value=0)
15
+
16
+ # Perform calculation based on the selected operation
17
+ if operation == "Add":
18
+ result = num1 + num2
19
+ elif operation == "Subtract":
20
+ result = num1 - num2
21
+ elif operation == "Multiply":
22
+ result = num1 * num2
23
+ elif operation == "Divide":
24
+ # Check for division by zero
25
+ if num2 != 0:
26
+ result = num1 / num2
27
+ else:
28
+ result = "Error: Division by Zero"
29
+
30
+ # Display the result
31
+ st.write(f"Result: {result}")