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