Skip to content

Commit 1e1ecbb

Browse files
authored
Create functions_kayra_oz.py
1 parent 8cfff6e commit 1e1ecbb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎Week04/functions_kayra_oz.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import inspect
2+
from typing import Tuple, Dict
3+
4+
custom_power = lambda x=0, /, e=1: x**e
5+
6+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
7+
"""
8+
Computes the custom equation (x**a + y**b) / c.
9+
10+
:param x: First positional-only base integer.
11+
:param y: Second positional-only base integer.
12+
:param a: First positional-or-keyword exponent integer.
13+
:param b: Second positional-or-keyword exponent integer.
14+
:param c: Keyword-only divisor integer.
15+
:return: The result of the equation as a float.
16+
"""
17+
return float((x**a + y**b) / c)
18+
19+
def fn_w_counter() -> Tuple[int, Dict[str, int]]:
20+
if not hasattr(fn_w_counter, "caller_counts"):
21+
fn_w_counter.caller_counts = {}
22+
fn_w_counter.total_calls = 0
23+
24+
frame = inspect.currentframe().f_back
25+
caller_name = frame.f_globals.get('__name__', 'unknown')
26+
27+
fn_w_counter.total_calls += 1
28+
fn_w_counter.caller_counts[caller_name] = fn_w_counter.caller_counts.get(caller_name, 0) + 1
29+
30+
return (fn_w_counter.total_calls, fn_w_counter.caller_counts)

0 commit comments

Comments
 (0)