Skip to content

Commit 347bc94

Browse files
committed
Add Week04 homework
1 parent 14f3ba0 commit 347bc94

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 (x**a + y**b) / c.
9+
10+
:param x: base of the first term (positional-only)
11+
:param y: base of the second term (positional-only)
12+
:param a: exponent of x
13+
:param b: exponent of y
14+
:param c: divisor (keyword-only)
15+
:return: the result of (x**a + y**b) / c
16+
"""
17+
for name, value in (("x", x), ("y", y), ("a", a), ("b", b), ("c", c)):
18+
if not isinstance(value, int):
19+
raise TypeError(f"{name} must be an int")
20+
return (x**a + y**b) / c
21+
22+
23+
_counter = 0
24+
25+
26+
def fn_w_counter() -> (int, dict[str, int]):
27+
global _counter
28+
_counter += 1
29+
return _counter, {__name__: _counter}

0 commit comments

Comments
 (0)