Tanseer45203 commited on
Commit
d1cc203
·
verified ·
1 Parent(s): f1cf37d

Create App. Py

Browse files
Files changed (1) hide show
  1. App. Py +30 -0
App. Py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title of the app
4
+ st.title("Simple Calculator")
5
+
6
+ # Input fields for numbers
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
+ # Select operation
11
+ operation = st.radio("Choose an operation", ["Addition", "Subtraction", "Multiplication", "Division"])
12
+
13
+ # Perform Calculation
14
+ result = None
15
+ if st.button("Calculate"):
16
+ if operation == "Addition":
17
+ result = num1 + num2
18
+ elif operation == "Subtraction":
19
+ result = num1 - num2
20
+ elif operation == "Multiplication":
21
+ result = num1 * num2
22
+ elif operation == "Division":
23
+ if num2 != 0:
24
+ result = num1 / num2
25
+ else:
26
+ st.error("Error: Division by zero is not allowed!")
27
+
28
+ # Display Result
29
+ if result is not None:
30
+ st.success(f"Result: {result}")