Skip to content

Commit 1666ebc

Browse files
authored
Implement custom power and equation functions
Adds custom power and equation functions with type hints.
1 parent 71f5b39 commit 1666ebc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 result.
6+
7+
:param x: Base number 1
8+
:param y: Base number 2
9+
:param a: Exponent for x
10+
:param b: Exponent for y
11+
:param c: Divisor
12+
:return: The calculated result as a float
13+
"""
14+
if not all(isinstance(arg, int) for arg in [x, y, a, b, c]):
15+
raise TypeError("All arguments must be integers.")
16+
return float((x ** a + y ** b) / c)
17+
18+
def fn_w_counter() -> (int, dict[str, int]):
19+
if not hasattr(fn_w_counter, "count"):
20+
fn_w_counter.count = 0
21+
fn_w_counter.count += 1
22+
return fn_w_counter.count, {__name__: fn_w_counter.count}

0 commit comments

Comments
 (0)