Skip to content

Commit 80130a8

Browse files
authored
Update functions_esra_kaya.py
1 parent 4af23b8 commit 80130a8

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

Week04/functions_esra_kaya.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
1-
custom_power = lambda x=0, /, e=1: x ** e
1+
custom_power= lambda x=0,/,e=1: x**e
22

3-
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
3+
def custom_equation(x:int=0,y:int=0,/,a:int=1,b:int=1,*,c:int=1)->float:
44
"""
5-
Calculate the result of the equation (x**a + y**b) / c.
6-
7-
:param x: Positional-only integer with default value 0
8-
:param y: Positional-only integer with default value 0
9-
:param a: Positional-or-keyword integer with default value 1
10-
:param b: Positional-or-keyword integer with default value 1
11-
:param c: Keyword-only integer with default value 1
12-
:return: A float that is the result of the equation (x**a + y**b) / c
5+
This function calculates a custom equation that.
6+
7+
:param x: Positional-only parameter, default value is 0.
8+
:param y: Positional-only parameter, default value is 0.
9+
:param a: Exponent for `x`, default value is 1.
10+
:param b: Exponent for `y`, default value is 1.
11+
:param c: Divisor of the equation, default value is 1.
12+
13+
:type x: int
14+
:type y: int
15+
:type a: int
16+
:type b: int
17+
:type c: int
18+
19+
:return: The result of the custom equation ((x^a)+(y^b))/c.
20+
:rtype: float
1321
"""
1422
return (x**a + y**b) / c
1523

16-
def fn_w_counter():
17-
fn_w_counter.counter += 1
18-
if not hasattr(fn_w_counter, 'call_dict'):
19-
fn_w_counter.call_dict = {}
2024

21-
caller = '__main__'
22-
if caller in fn_w_counter.call_dict:
23-
fn_w_counter.call_dict[caller] += 1
24-
else:
25-
fn_w_counter.call_dict[caller] = 1
25+
def fn_w_counter() -> (int, dict[str, int]):
26+
if not hasattr(fn_w_counter, "call_counter"):
27+
fn_w_counter.call_counter = 0
28+
fn_w_counter.caller_counts = {}
2629

27-
return fn_w_counter.counter, fn_w_counter.call_dict
30+
caller = __name__
31+
fn_w_counter.call_counter += 1
32+
33+
if caller not in fn_w_counter.caller_counts:
34+
fn_w_counter.caller_counts[caller] = 1
35+
else:
36+
fn_w_counter.caller_counts[caller] += 1
2837

38+
return fn_w_counter.call_counter, fn_w_counter.caller_counts

0 commit comments

Comments
 (0)