Skip to content

Commit b87ce2e

Browse files
Add custom power and equation functions with counter
1 parent f083b29 commit b87ce2e

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import inspect
2+
3+
custom_power = lambda x=0, /, e=1: x ** e
4+
5+
6+
def custom_equation(x: int = 0, y: int = 0, /,
7+
a: int = 1, b: int = 1, *, c: int = 1) -> float:
8+
9+
10+
11+
return (x**a + y**b) / c
12+
13+
14+
counter = 0
15+
callers = {}
16+
17+
18+
def fn_w_counter() -> tuple:
19+
global counter
20+
21+
counter += 1
22+
23+
caller = inspect.currentframe().f_back.f_globals["__name__"]
24+
25+
if caller in callers:
26+
callers[caller] += 1
27+
else:
28+
callers[caller] = 1
29+
30+
return counter, callers.copy()

0 commit comments

Comments
 (0)