Skip to content

Commit 4d84731

Browse files
authored
Merge pull request canbula#703 from beytullaharslannn/patch-3
Add custom functions for power and counting calls Beytullah Arslan
2 parents 4653d71 + 219486f commit 4d84731

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
custom_power = lambda x=0,/,e=1: x ** e
2+
3+
def custom_equation(x: int = 0 , y: int = 0, / , a: int = 1, b: int = 1, * , c: int = 1) -> float:
4+
"""
5+
Calculate the custom equation (x**a + y**b) / c.
6+
7+
:param x: first base
8+
:param y: second base
9+
:param a: first exponent
10+
:param b: second exponent
11+
:param c: divisor
12+
:return: the computed float result
13+
"""
14+
return (x**a + y**b) / c
15+
16+
17+
def fn_w_counter() -> (int, dict[str, int]):
18+
if not hasattr(fn_w_counter,'call_counter'):
19+
fn_w_counter.call_counter = 0
20+
fn_w_counter.caller_dict = {}
21+
caller = __name__
22+
fn_w_counter.call_counter += 1
23+
if caller in fn_w_counter.caller_dict:
24+
fn_w_counter.caller_dict[caller] += 1
25+
else:
26+
fn_w_counter.caller_dict[caller] = 1
27+
return fn_w_counter.call_counter,fn_w_counter.caller_dict

0 commit comments

Comments
 (0)