Skip to content

Commit a2de7eb

Browse files
authored
Create functions_burak_talha_memis.py
1 parent fe4037f commit a2de7eb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
custom_power = lambda x = 0,/,e = 1: x**e
2+
3+
def custom_equation(x = 0,y = 0,/,a = 1,b = 1, * ,c = 1)->float:
4+
return (x**a + y**b) / c
5+
'''
6+
x is positional-only with default value 0
7+
y is positional-only with default value 0
8+
a is positional-or-keyword with default value 1
9+
b is positional-or-keyword with default value 1
10+
c is keyword-only with default value 1
11+
'''
12+
13+
def fn_w_counter() -> (int, dict[str,int]):
14+
if not hasattr(fn_w_counter, 'counter'):
15+
fn_w_counter.counter = 0
16+
17+
fn_w_counter.counter += 1
18+
19+
if not hasattr(fn_w_counter, 'callers'):
20+
fn_w_counter.callers = {f"{__name__}": 1}
21+
else:
22+
if __name__ in fn_w_counter.callers:
23+
fn_w_counter.callers[__name__] += 1
24+
else:
25+
fn_w_counter.callers[__name__] = 1
26+
27+
print(f"This function has been called {fn_w_counter.counter} times")
28+
print(f"Callers: {fn_w_counter.callers}")

0 commit comments

Comments
 (0)