|
| 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 | + Calculate a custom equation based on the provided parameters. |
| 6 | +
|
| 7 | + The function computes the result of the equation: |
| 8 | + (x^a + y^b) / c |
| 9 | +
|
| 10 | + :param x: The first integer value (positional-only, default is 0). |
| 11 | + :param y: The second integer value (positional-only, default is 0). |
| 12 | + :param a: The exponent for x (positional or keyword, default is 1). |
| 13 | + :param b: The exponent for y (positional or keyword, default is 1). |
| 14 | + :param c: The divisor (keyword-only, default is 1). |
| 15 | + :raises ValueError: If the divisor c is 0 (division by zero). |
| 16 | + :return: The result of the equation as a float. |
| 17 | + :rtype: float |
| 18 | + """ |
| 19 | + if c == 0: |
| 20 | + raise ZeroDivisionError("Division by zero is not allowed.") |
| 21 | + return (x**a + y**b) / c |
| 22 | + |
| 23 | +def fn_w_counter() -> (int, dict[str, int]): |
| 24 | + if not hasattr(fn_w_counter, "call_counter"): |
| 25 | + fn_w_counter.call_counter = 0 |
| 26 | + fn_w_counter.caller_counts = {} |
| 27 | + |
| 28 | + caller = __name__ |
| 29 | + fn_w_counter.call_counter += 1 |
| 30 | + |
| 31 | + if caller not in fn_w_counter.caller_counts: |
| 32 | + fn_w_counter.caller_counts[caller] = 1 |
| 33 | + else: |
| 34 | + fn_w_counter.caller_counts[caller] += 1 |
| 35 | + |
| 36 | + return fn_w_counter.call_counter, fn_w_counter.caller_counts |
0 commit comments