Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Week04/functions_buse_demirbas
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
exec("custom_power = lambda x=0, /, e=1: x ** e", globals())


def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
"""
Computes (x**a + y**b) / c.

:param x: Base for the first term. Default 0.
:type x: int
:param y: Base for the second term. Default 0.
:type y: int
:param a: Exponent for x. Default 1.
:type a: int
:param b: Exponent for y. Default 1.
:type b: int
:param c: Divisor. Default 1.
:type c: int
:return: The result of (x**a + y**b) / c.
:rtype: float
"""
if not isinstance(x, int) or not isinstance(y, int):
raise TypeError("x and y must be integers")
if not isinstance(a, int) or not isinstance(b, int) or not isinstance(c, int):
raise TypeError("a, b and c must be integers")
return (x ** a + y ** b) / c


_counter = {}

def fn_w_counter() -> (int, dict[str, int]):
_counter[__name__] = _counter.get(__name__, 0) + 1
total = _counter[__name__]
return (total, {__name__: total})
Loading