Skip to content

Commit 86c0f4f

Browse files
authored
Add custom_power and custom_equation functions
Implement custom power and equation functions with a call counter.
1 parent f083b29 commit 86c0f4f

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

‎Week04/functions_melda_gungor.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
Calculates the custom equation.
6+
:param x: first base
7+
:type x: int
8+
:param y: second base
9+
:type y: int
10+
:param a: exponent for x
11+
:type a: int
12+
:param b: exponent for y
13+
:type b: int
14+
:param c: divisor
15+
:type c: int
16+
:return: the result of (x**a + y**b) / c
17+
:rtype: float """
18+
19+
return float((x**a + y**b) / c)
20+
21+
22+
def fn_w_counter() -> tuple[int , dict[str,int]]:
23+
if not hasattr(fn_w_counter,"total_count"):
24+
fn_w_counter.total_count = 0
25+
fn_w_counter.call_records = {}
26+
27+
caller = __name__
28+
fn_w_counter.total_count += 1
29+
30+
if caller not in fn_w_counter.call_records:
31+
fn_w_counter.call_records[caller] = 1
32+
else:
33+
fn_w_counter.call_records[caller] += 1
34+
35+
return fn_w_counter.total_count, fn_w_counter.call_records
36+
37+
38+

0 commit comments

Comments
 (0)