Skip to content

Commit 5a5b1e3

Browse files
authored
Fix return statement formatting in functions_esra_sepik.py
1 parent 8415c79 commit 5a5b1e3

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎Week04/functions_esra_sepik.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import inspect
2+
3+
custom_power = lambda x=0, /, e=1: x ** e
4+
5+
6+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
7+
"""
8+
Calculates an equation using the given integers.
9+
10+
The formula is ``(x ** a + y ** b) / c``.
11+
12+
:param x: positional-only value, defaults to 0
13+
:type x: int
14+
:param y: positional-only value, defaults to 0
15+
:type y: int
16+
:param a: exponent for x, defaults to 1
17+
:type a: int
18+
:param b: exponent for y, defaults to 1
19+
:type b: int
20+
:param c: keyword-only divisor, defaults to 1
21+
:type c: int
22+
:returns: the result of the equation
23+
:rtype: float
24+
"""
25+
numerator = pow(x, a) + pow(y, b)
26+
return numerator / c
27+
28+
29+
_call_count = 0
30+
_caller_counts: dict[str, int] = {}
31+
32+
33+
def fn_w_counter() -> tuple[int, dict[str, int]]:
34+
global _call_count
35+
frame = inspect.stack()[1].frame
36+
caller_name = frame.f_globals["__name__"]
37+
del frame
38+
_call_count += 1
39+
_caller_counts[caller_name] = _caller_counts.setdefault(caller_name, 0) + 1
40+
return (_call_count, dict(_caller_counts))

0 commit comments

Comments
 (0)