Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,19 +11,19 @@ def main():
|
|
11 |
for i in range(num_inputs):
|
12 |
numbers.append(st.number_input(f"Enter number {i+1}", value=0.0, format="%.2f"))
|
13 |
|
14 |
-
operation = st.selectbox("Choose an operation", ["
|
15 |
|
16 |
result = numbers[0]
|
17 |
if st.button("Calculate"):
|
18 |
try:
|
19 |
-
for num in numbers[1:]:
|
20 |
-
if operation == "
|
21 |
result += num
|
22 |
-
elif operation == "
|
23 |
result -= num
|
24 |
-
elif operation == "
|
25 |
result *= num
|
26 |
-
elif operation == "
|
27 |
if num != 0:
|
28 |
result /= num
|
29 |
else:
|
@@ -35,8 +35,13 @@ def main():
|
|
35 |
else:
|
36 |
st.error("Cannot find modulus with zero!")
|
37 |
return
|
38 |
-
elif operation == "Exponentiation":
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
elif operation == "Floor Division":
|
41 |
if num != 0:
|
42 |
result //= num
|
@@ -49,4 +54,4 @@ def main():
|
|
49 |
st.error(f"An error occurred: {e}")
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
-
main()
|
|
|
11 |
for i in range(num_inputs):
|
12 |
numbers.append(st.number_input(f"Enter number {i+1}", value=0.0, format="%.2f"))
|
13 |
|
14 |
+
operation = st.selectbox("Choose an operation", ["Addition", "Subtraction", "Multiplication", "Division", "Modulus", "Exponentiation (Base^Power)", "Floor Division"])
|
15 |
|
16 |
result = numbers[0]
|
17 |
if st.button("Calculate"):
|
18 |
try:
|
19 |
+
for index, num in enumerate(numbers[1:]):
|
20 |
+
if operation == "Addition":
|
21 |
result += num
|
22 |
+
elif operation == "Subtraction":
|
23 |
result -= num
|
24 |
+
elif operation == "Multiplication":
|
25 |
result *= num
|
26 |
+
elif operation == "Division":
|
27 |
if num != 0:
|
28 |
result /= num
|
29 |
else:
|
|
|
35 |
else:
|
36 |
st.error("Cannot find modulus with zero!")
|
37 |
return
|
38 |
+
elif operation == "Exponentiation (Base^Power)":
|
39 |
+
if index == 0:
|
40 |
+
base = result
|
41 |
+
power = num
|
42 |
+
result = base ** power
|
43 |
+
else:
|
44 |
+
result **= num
|
45 |
elif operation == "Floor Division":
|
46 |
if num != 0:
|
47 |
result //= num
|
|
|
54 |
st.error(f"An error occurred: {e}")
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
+
main()
|