Skip to content

Commit df805cf

Browse files
committed
add: functions homework
1 parent 1556fac commit df805cf

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)