Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import math
|
|
| 3 |
import time
|
| 4 |
|
| 5 |
# Title with Emoji
|
| 6 |
-
st.title("๐ซ Advanced Calculator with
|
| 7 |
|
| 8 |
# Animation for menu reveal
|
| 9 |
with st.expander("๐๏ธ Open the Menu (Click Me!)"):
|
|
@@ -28,7 +28,7 @@ with st.expander("๐๏ธ Open the Menu (Click Me!)"):
|
|
| 28 |
[
|
| 29 |
"โ Addition", "โ Subtraction", "โ๏ธ Multiplication", "โ Division",
|
| 30 |
"๐ข Exponentiation", "๐ Square Root", "๐ Logarithm", "๐ก Factorial",
|
| 31 |
-
"๐ Trigonometry (sin, cos, tan)"
|
| 32 |
]
|
| 33 |
)
|
| 34 |
|
|
@@ -96,4 +96,44 @@ elif operation == "๐ Trigonometry (sin, cos, tan)":
|
|
| 96 |
radians = math.radians(angle)
|
| 97 |
st.write(f"Sin({angle}ยฐ): {math.sin(radians):.4f}")
|
| 98 |
st.write(f"Cos({angle}ยฐ): {math.cos(radians):.4f}")
|
| 99 |
-
st.write(f"Tan({angle}ยฐ): {math.tan(radians):.4f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import time
|
| 4 |
|
| 5 |
# Title with Emoji
|
| 6 |
+
st.title("๐ซ Advanced Calculator with More Operations ๐ป")
|
| 7 |
|
| 8 |
# Animation for menu reveal
|
| 9 |
with st.expander("๐๏ธ Open the Menu (Click Me!)"):
|
|
|
|
| 28 |
[
|
| 29 |
"โ Addition", "โ Subtraction", "โ๏ธ Multiplication", "โ Division",
|
| 30 |
"๐ข Exponentiation", "๐ Square Root", "๐ Logarithm", "๐ก Factorial",
|
| 31 |
+
"๐ Trigonometry (sin, cos, tan)", "๐งฎ Percentage", "โ Modulus", "๐ Inverse (1/x)", "โก Absolute Value"
|
| 32 |
]
|
| 33 |
)
|
| 34 |
|
|
|
|
| 96 |
radians = math.radians(angle)
|
| 97 |
st.write(f"Sin({angle}ยฐ): {math.sin(radians):.4f}")
|
| 98 |
st.write(f"Cos({angle}ยฐ): {math.cos(radians):.4f}")
|
| 99 |
+
st.write(f"Tan({angle}ยฐ): {math.tan(radians):.4f}")
|
| 100 |
+
|
| 101 |
+
elif operation == "๐งฎ Percentage":
|
| 102 |
+
# Calculate percentage
|
| 103 |
+
total = st.number_input("Enter the total value: ๐ท๏ธ", value=1.0)
|
| 104 |
+
portion = st.number_input("Enter the portion value: ๐ท๏ธ", value=0.0)
|
| 105 |
+
if st.button("๐ Calculate Percentage"):
|
| 106 |
+
show_animation()
|
| 107 |
+
if total != 0:
|
| 108 |
+
result = (portion / total) * 100
|
| 109 |
+
st.success(f"Result: {result}%")
|
| 110 |
+
else:
|
| 111 |
+
st.error("๐ซ Error: Total value cannot be zero!")
|
| 112 |
+
|
| 113 |
+
elif operation == "โ Modulus":
|
| 114 |
+
# Calculate modulus
|
| 115 |
+
num1 = st.number_input("Enter the first number: ๐ท๏ธ", value=0.0)
|
| 116 |
+
num2 = st.number_input("Enter the second number: ๐ท๏ธ", value=0.0)
|
| 117 |
+
if st.button("๐ Calculate Modulus"):
|
| 118 |
+
show_animation()
|
| 119 |
+
if num2 != 0:
|
| 120 |
+
st.success(f"Result: {num1 % num2}")
|
| 121 |
+
else:
|
| 122 |
+
st.error("๐ซ Error: Modulus undefined for division by zero!")
|
| 123 |
+
|
| 124 |
+
elif operation == "๐ Inverse (1/x)":
|
| 125 |
+
# Calculate inverse
|
| 126 |
+
num = st.number_input("Enter the number: ๐ท๏ธ", value=0.0)
|
| 127 |
+
if st.button("๐ Calculate Inverse"):
|
| 128 |
+
show_animation()
|
| 129 |
+
if num != 0:
|
| 130 |
+
st.success(f"Result: {1 / num}")
|
| 131 |
+
else:
|
| 132 |
+
st.error("๐ซ Error: Inverse undefined for zero!")
|
| 133 |
+
|
| 134 |
+
elif operation == "โก Absolute Value":
|
| 135 |
+
# Calculate absolute value
|
| 136 |
+
num = st.number_input("Enter the number: ๐ท๏ธ", value=0.0)
|
| 137 |
+
if st.button("๐ Calculate Absolute Value"):
|
| 138 |
+
show_animation()
|
| 139 |
+
st.success(f"Result: {abs(num)}")
|