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
32 changes: 32 additions & 0 deletions Week04/functions_turhan_gunduzoglu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys

custom_power = lambda x, /, e=1: x ** e

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

:param x: Base for the first term; positional-only; default 0.
:type x: int
:param y: Base for the second term; positional-only; default 0.
:type y: int
:param a: Exponent for x; positional-or-keyword; default 1.
:type a: int
:param b: Exponent for y; positional-or-keyword; default 1.
:type b: int
:param c: Divisor; keyword-only; default 1.
:type c: int
:return: (x**a + y**b) / c
:rtype: float
"""
return (x ** a + y ** b) / c

_counter_total = 0
_counter_callers = {}

def fn_w_counter() -> tuple:
global _counter_total, _counter_callers
caller = sys._getframe(1).f_globals.get("__name__", "<unknown>")
_counter_total += 1
_counter_callers[caller] = _counter_callers.get(caller, 0) + 1
return (_counter_total, dict(_counter_callers))
Loading