abdullahshoaib5616 commited on
Commit
f5f38fc
·
verified ·
1 Parent(s): bd377f6

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
+ # User input for the first number
7
+ num1 = st.number_input("Enter the first number:", value=0)
8
+
9
+ # User input for the second number
10
+ num2 = st.number_input("Enter the second number:", value=0)
11
+
12
+ # Dropdown for selecting operation
13
+ operation = st.selectbox("Choose the operation", ["Add", "Subtract", "Multiply", "Divide"])
14
+
15
+ # Perform calculation based on selected operation
16
+ if operation == "Add":
17
+ result = num1 + num2
18
+ elif operation == "Subtract":
19
+ result = num1 - num2
20
+ elif operation == "Multiply":
21
+ result = num1 * num2
22
+ elif operation == "Divide":
23
+ if num2 != 0:
24
+ result = num1 / num2
25
+ else:
26
+ result = "Error! Division by zero."
27
+
28
+ # Display the result
29
+ st.write(f"The result of {operation} is: {result}")