Skip to content

Commit e12f4e3

Browse files
authored
create functions_rafet_taskin.py
1 parent 72a3977 commit e12f4e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Week04/functions_rafet_taskin.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
custom_power = lambda x=0, /, e=1: x ** e
2+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
3+
"""
4+
Computes a custom equation.
5+
6+
:param x: First base (positional only)
7+
:param y: Second base (positional only)
8+
:param a: First exponent
9+
:param b: Second exponent
10+
:param c: Divisor (keyword only)
11+
:return: The result of (x^a + y^b) / c
12+
"""
13+
14+
for param_name, value in [('x', x), ('y', y), ('a', a), ('b', b), ('c', c)]:
15+
if not isinstance(value, int):
16+
raise TypeError(f"{param_name} must be an integer")
17+
18+
return float((x ** a + y ** b) / c)
19+
20+
21+
def fn_w_counter() -> (int, dict[str, int]):
22+
if not hasattr(fn_w_counter, "count"):
23+
fn_w_counter.count = 0
24+
25+
fn_w_counter.count += 1
26+
27+
return fn_w_counter.count, {__name__: fn_w_counter.count}

0 commit comments

Comments
 (0)