Skip to content

Commit 25bda4d

Browse files
authored
Create functions_elif_gulseren.py
1 parent 2889489 commit 25bda4d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎Week04/functions_elif_gulseren.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
Calculates the result of a custom mathematical equation.
6+
7+
:param x: The first base (positional-only).
8+
:param y: The second base (positional-only).
9+
:param a: The exponent for the first base (positional-or-keyword).
10+
:param b: The exponent for the second base (positional-or-keyword).
11+
:param c: The divisor (keyword-only).
12+
:return: The result of the equation (x**a + y**b) / c as a float.
13+
"""
14+
if type(x) is not int or type(y) is not int or type(a) is not int or type(b) is not int or type(c) is not int:
15+
raise TypeError("All arguments must be integers.")
16+
17+
return float((x ** a + y ** b) / c)
18+
19+
def fn_w_counter() -> (int, dict[str, int]):
20+
if not hasattr(fn_w_counter, "total_calls"):
21+
fn_w_counter.total_calls = 0
22+
fn_w_counter.caller_dict = {}
23+
24+
fn_w_counter.total_calls += 1
25+
26+
caller = __name__
27+
28+
if caller not in fn_w_counter.caller_dict:
29+
fn_w_counter.caller_dict[caller] = 0
30+
fn_w_counter.caller_dict[caller] += 1
31+
32+
return fn_w_counter.total_calls, fn_w_counter.caller_dict

0 commit comments

Comments
 (0)