Skip to content

Commit 8c6ae78

Browse files
authored
Update functions_miray_cengil.py
1 parent 5bf3e95 commit 8c6ae78

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Week04/functions_miray_cengil.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
custom_power = lambda x=0, /, e=1: x ** e
22

33
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
4-
54
"""
65
A function that calculates the custom equation:
76
@@ -14,14 +13,12 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int
1413
:param c: keyword-only integer, default 1
1514
:return: Result of the equation as a float
1615
"""
16+
if c == 0:
17+
raise ValueError("Division by Zero Exception")
1718
return (x**a + y**b) / c
1819

19-
from collections import defaultdict
20-
import inspect
21-
22-
call_count = defaultdict(int)
23-
2420
def fn_w_counter() -> (int, dict[str, int]):
21+
# Keep track of the call count and caller info without using modules
2522
if not hasattr(fn_w_counter, "call_counter"):
2623
fn_w_counter.call_counter = 0
2724
fn_w_counter.caller_count_dict = {}
@@ -30,11 +27,10 @@ def fn_w_counter() -> (int, dict[str, int]):
3027
caller_name = __name__
3128
fn_w_counter.call_counter += 1
3229

33-
# If the caller is already in the dictionary, increment its value
30+
# Increment the call count for this caller
3431
if caller_name in fn_w_counter.caller_count_dict:
3532
fn_w_counter.caller_count_dict[caller_name] += 1
3633
else:
37-
# Otherwise, add it as a new key
3834
fn_w_counter.caller_count_dict[caller_name] = 1
3935

4036
# Return the total call count and the caller information

0 commit comments

Comments
 (0)