hbhamzabaig commited on
Commit
67befcb
·
verified ·
1 Parent(s): 012e995

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Set the title of the web app
4
+ st.title("Simple Calculator")
5
+
6
+ # Create input fields for numbers
7
+ num1 = st.number_input("Enter first number", value=0)
8
+ num2 = st.number_input("Enter second number", value=0)
9
+
10
+ # Create a dropdown menu for selecting operations
11
+ operation = st.selectbox("Select operation", ("Add", "Subtract", "Multiply", "Divide"))
12
+
13
+ # Perform the calculation based on the selected operation
14
+ if operation == "Add":
15
+ result = num1 + num2
16
+ elif operation == "Subtract":
17
+ result = num1 - num2
18
+ elif operation == "Multiply":
19
+ result = num1 * num2
20
+ elif operation == "Divide":
21
+ if num2 != 0:
22
+ result = num1 / num2
23
+ else:
24
+ result = "Cannot divide by zero!"
25
+
26
+ # Display the result
27
+ st.write("Result:", result)