zeeshan4801 commited on
Commit
0525de1
·
verified ·
1 Parent(s): 63debad

Update app.py

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