Skip to content

Commit 490e00a

Browse files
authored
Add files via upload
1 parent fe4037f commit 490e00a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Week03/functions_ali_duman.py

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

0 commit comments

Comments
 (0)