MuhammadSajid commited on
Commit
e18f3b2
·
verified ·
1 Parent(s): e43c01b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -7,7 +7,19 @@ num1 = st.number_input("Enter first number", value=0.0)
7
  num2 = st.number_input("Enter second number", value=0.0)
8
 
9
  # Operation selection
10
- operation = st.selectbox("Select Operation", ["Addition (+)", "Subtraction (-)", "Multiplication (×)", "Division (÷)"])
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Calculate result
13
  if st.button("Calculate"):
@@ -26,3 +38,21 @@ if st.button("Calculate"):
26
  st.success(f"Result: {result}")
27
  else:
28
  st.error("Error: Cannot divide by zero")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  num2 = st.number_input("Enter second number", value=0.0)
8
 
9
  # Operation selection
10
+ operation = st.selectbox(
11
+ "Select Operation",
12
+ [
13
+ "Addition (+)",
14
+ "Subtraction (-)",
15
+ "Multiplication (×)",
16
+ "Division (÷)",
17
+ "Modulus (%)",
18
+ "Exponentiation (^)",
19
+ "Floor Division (//)",
20
+ "Average"
21
+ ]
22
+ )
23
 
24
  # Calculate result
25
  if st.button("Calculate"):
 
38
  st.success(f"Result: {result}")
39
  else:
40
  st.error("Error: Cannot divide by zero")
41
+ elif operation == "Modulus (%)":
42
+ if num2 != 0:
43
+ result = num1 % num2
44
+ st.success(f"Result: {result}")
45
+ else:
46
+ st.error("Error: Cannot perform modulus with zero")
47
+ elif operation == "Exponentiation (^)":
48
+ result = num1 ** num2
49
+ st.success(f"Result: {result}")
50
+ elif operation == "Floor Division (//)":
51
+ if num2 != 0:
52
+ result = num1 // num2
53
+ st.success(f"Result: {result}")
54
+ else:
55
+ st.error("Error: Cannot perform floor division by zero")
56
+ elif operation == "Average":
57
+ result = (num1 + num2) / 2
58
+ st.success(f"Result: {result}")