|
| 1 | +custom_power = lambda x=0, /, e=1: x ** e |
| 2 | + |
| 3 | +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: |
| 4 | + """ |
| 5 | + A function that calculates the custom equation: |
| 6 | + |
| 7 | + (x**a + y**b) / c |
| 8 | + |
| 9 | + :param x: positional-only integer, default 0 |
| 10 | + :param y: positional-only integer, default 0 |
| 11 | + :param a: positional-or-keyword integer, default 1 |
| 12 | + :param b: positional-or-keyword integer, default 1 |
| 13 | + :param c: keyword-only integer, default 1 |
| 14 | + :return: Result of the equation as a float |
| 15 | + """ |
| 16 | + if c == 0: |
| 17 | + raise ValueError("Division by Zero Exception") |
| 18 | + return (x**a + y**b) / c |
| 19 | + |
| 20 | +def fn_w_counter() -> (int, dict[str, int]): |
| 21 | + # Keep track of the call count and caller info without using modules |
| 22 | + if not hasattr(fn_w_counter, "call_counter"): |
| 23 | + fn_w_counter.call_counter = 0 |
| 24 | + fn_w_counter.caller_count_dict = {} |
| 25 | + |
| 26 | + # Get the name of the caller |
| 27 | + caller_name = __name__ |
| 28 | + fn_w_counter.call_counter += 1 |
| 29 | + |
| 30 | + # Increment the call count for this caller |
| 31 | + if caller_name in fn_w_counter.caller_count_dict: |
| 32 | + fn_w_counter.caller_count_dict[caller_name] += 1 |
| 33 | + else: |
| 34 | + fn_w_counter.caller_count_dict[caller_name] = 1 |
| 35 | + |
| 36 | + # Return the total call count and the caller information |
| 37 | + return fn_w_counter.call_counter, fn_w_counter.caller_count_dict |
0 commit comments