Skip to content

Commit df2c2c8

Browse files
authored
Add files via upload
1 parent bfca1da commit df2c2c8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Week03/functions_ali_duman.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
custom_power = lambda x=0, /, e=1: x**e
2+
3+
4+
def custom_equation(x: int=0, y: int=0, /, a: int=1, b: int=1,*, c: int=1) -> float:
5+
"""
6+
Calculate a custom equation based on the provided parameters.
7+
8+
Parameters:
9+
x (int, optional): The base value for the first term. Defaults to 0.
10+
y (int, optional): The base value for the second term. Defaults to 0.
11+
a (int, optional): The exponent for the first term. Defaults to 1.
12+
b (int, optional): The exponent for the second term. Defaults to 1.
13+
c (int, optional): The divisor for the final calculation. Defaults to 1.
14+
15+
Returns:
16+
float: The result of the custom equation (x**a + y**b) / c.
17+
"""
18+
return (x**a + y**b) / c
19+
20+
21+
def fn_w_counter() -> tuple[int, dict[str, int]]:
22+
# Get the caller's name
23+
caller = globals()['__name__']
24+
25+
# Initialize function attributes
26+
if not hasattr(fn_w_counter, "total_calls"):
27+
fn_w_counter.total_calls = 0
28+
fn_w_counter.calls_per_caller = {}
29+
30+
# Increment the total call count
31+
fn_w_counter.total_calls += 1
32+
33+
# Update the call count for this caller
34+
if caller in fn_w_counter.calls_per_caller:
35+
fn_w_counter.calls_per_caller[caller] += 1
36+
else:
37+
fn_w_counter.calls_per_caller[caller] = 1
38+
39+
# Return the total number of calls and the dictionary of calls per caller
40+
return fn_w_counter.total_calls, fn_w_counter.calls_per_caller

0 commit comments

Comments
 (0)