Amelia-James commited on
Commit
2e44bb7
1 Parent(s): a3f9a68

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title of the application
4
+ st.title("Simple Calculator")
5
+
6
+ # Input fields for the numbers
7
+ num1 = st.number_input("Enter the first number", format="%f")
8
+ num2 = st.number_input("Enter the second number", format="%f")
9
+
10
+ # Select the operation
11
+ operation = st.selectbox(
12
+ "Select an operation",
13
+ ["Addition", "Subtraction", "Multiplication", "Division"]
14
+ )
15
+
16
+ # Perform the calculation
17
+ if st.button("Calculate"):
18
+ if operation == "Addition":
19
+ result = num1 + num2
20
+ st.success(f"The result of addition is: {result}")
21
+ elif operation == "Subtraction":
22
+ result = num1 - num2
23
+ st.success(f"The result of subtraction is: {result}")
24
+ elif operation == "Multiplication":
25
+ result = num1 * num2
26
+ st.success(f"The result of multiplication is: {result}")
27
+ elif operation == "Division":
28
+ if num2 == 0:
29
+ st.error("Error: Division by zero is not allowed")
30
+ else:
31
+ result = num1 / num2
32
+ st.success(f"The result of division is: {result}")