Skip to content

Commit 8ba6c7a

Browse files
authored
Merge pull request #597 from miraycengil/patch-5
functions_miray_cengil.py
2 parents 0342703 + 8c6ae78 commit 8ba6c7a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Week04/functions_miray_cengil.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)