BQGamer commited on
Commit
572616b
·
verified ·
1 Parent(s): 0bef430

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -1
app.py CHANGED
@@ -67,4 +67,44 @@ elif operation == "Trigonometric":
67
 
68
  # Logarithmic Operations
69
  elif operation == "Logarithmic":
70
- log_op = st.selectbox("Choose logarithmic operation",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  # Logarithmic Operations
69
  elif operation == "Logarithmic":
70
+ log_op = st.selectbox("Choose logarithmic operation", ("Log Base 10", "Natural Log"))
71
+ if log_op == "Log Base 10":
72
+ if num1 > 0:
73
+ result = math.log10(num1)
74
+ else:
75
+ result = "Error: Logarithm only defined for positive numbers"
76
+ elif log_op == "Natural Log":
77
+ if num1 > 0:
78
+ result = math.log(num1)
79
+ else:
80
+ result = "Error: Logarithm only defined for positive numbers"
81
+
82
+ # Factorial
83
+ elif operation == "Factorial":
84
+ if num1 >= 0 and num1 == int(num1):
85
+ result = math.factorial(int(num1))
86
+ else:
87
+ result = "Error: Factorial is only defined for non-negative integers"
88
+
89
+ # Percentage Calculation
90
+ elif operation == "Percentage":
91
+ percentage_op = st.selectbox("Choose percentage operation", ("Find Percentage", "Find Percentage of"))
92
+ if percentage_op == "Find Percentage":
93
+ result = (num1 * num2) / 100
94
+ elif percentage_op == "Find Percentage of":
95
+ result = (num1 * 100) / num2
96
+
97
+ # Memory Feature
98
+ elif operation == "Memory":
99
+ memory_op = st.selectbox("Choose memory operation", ("Store Result", "Recall Result", "Clear Memory"))
100
+ if memory_op == "Store Result":
101
+ st.session_state.memory = result
102
+ result = f"Result stored in memory: {st.session_state.memory}"
103
+ elif memory_op == "Recall Result":
104
+ result = f"Memory contains: {st.session_state.memory}"
105
+ elif memory_op == "Clear Memory":
106
+ st.session_state.memory = 0.0
107
+ result = "Memory cleared"
108
+
109
+ # Display the result
110
+ st.write(f"Result: {result}")