-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from bestetekceli/patch-3
Create functions_havva_beste_tekceli.py
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
custom_power = lambda x = 0 , / ,e = 1 : x ** e | ||
|
||
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: | ||
""" | ||
Calculate the result of a custom equation: | ||
:param x: number 1 | ||
:param y: number 2 | ||
:param a: exponent of number 1 | ||
:param b: exponent of number 2 | ||
:param c: number 3 | ||
:return: compute the result of (x**a + y**b) divided by c. | ||
""" | ||
return (x**a + y**b) / c | ||
|
||
|
||
def fn_w_counter() -> (int, dict[str, int]): | ||
""" | ||
Counts function calls and tracks caller modules. | ||
Returns: | ||
Tuple: (call_count, caller_dict) | ||
- call_count: Total number of times this function has been called. | ||
- caller: Dictionary of caller module names and their call counts. | ||
""" | ||
|
||
if not hasattr(fn_w_counter, "call_count"): | ||
fn_w_counter.call_count = 0 | ||
fn_w_counter.caller = {} | ||
caller_name = __name__ | ||
fn_w_counter.call_count += 1 | ||
if caller_name in fn_w_counter.caller: | ||
fn_w_counter.caller[caller_name] += 1 | ||
else: | ||
fn_w_counter.caller[caller_name] = 1 | ||
return fn_w_counter.call_count, fn_w_counter.caller | ||
|
||
|
||
|