Skip to content

Commit 622609a

Browse files
Implement custom power and equation functions
Added custom power and equation functions with a call counter.
1 parent 71f5b39 commit 622609a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
3+
custom_power = lambda x=0, /, e=1: x**e
4+
5+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
6+
return float((x**a + y**b) / c)
7+
8+
def fn_w_counter():
9+
if not hasattr(fn_w_counter, "calls"):
10+
fn_w_counter.calls = 0
11+
fn_w_counter.callers = {}
12+
13+
try:
14+
caller_name = sys._getframe(1).f_globals.get('__name__', '__main__')
15+
except:
16+
caller_name = "__main__"
17+
18+
fn_w_counter.calls += 1
19+
fn_w_counter.callers[caller_name] = fn_w_counter.callers.get(caller_name, 0) + 1
20+
21+
return (fn_w_counter.calls, fn_w_counter.callers)

0 commit comments

Comments
 (0)