nightprogrammer commited on
Commit
54b46fc
ยท
verified ยท
1 Parent(s): 0e1f4eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import math
3
  import time
4
 
5
  # Title with Emoji
6
- st.title("๐Ÿ’ซ Advanced Calculator with Menu Animation ๐Ÿ’ป")
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)}")