Skip to content

Commit 2f36ce4

Browse files
authored
Merge pull request #738 from Zeyneepsudee/patch-3
Add custom functions for power and equation calculations Zeynep Sude
2 parents 657bdcc + 5bea69e commit 2f36ce4

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
Computes (x**a + y**b) / c.
7+
8+
:param x: First base
9+
:param y: Second base
10+
:param a: Exponent of x
11+
:param b: Exponent of y
12+
:param c: Divisor
13+
:return: (x**a + y**b) / c
14+
"""
15+
if not all(isinstance(i, int) for i in (x, y, a, b, c)):
16+
raise TypeError("All parameters must be integers")
17+
return (x ** a + y ** b) / c
18+
19+
20+
counter = {}
21+
22+
23+
def fn_w_counter() -> (int, dict[str, int]):
24+
counter[__name__] = counter.get(__name__, 0) + 1
25+
return sum(counter.values()), counter

0 commit comments

Comments
 (0)