Skip to content

Commit f0c107d

Browse files
Implement custom power and equation functions
Added custom power and equation functions with a counter.
1 parent b60efee commit f0c107d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)