Skip to content

Commit a35cc10

Browse files
authored
Merge pull request #81 from selvanurKirac/patch-3
Create functions_selvanur_kirac.py
2 parents 24f27eb + 2076ab0 commit a35cc10

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Week03/functions_selvanur_kirac.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
This function adds power a of variable x and power b of variable y. Divides the result by variable c.
6+
:param x: First base
7+
:param y: Second base
8+
:param a: First exponent
9+
:param b: Second exponent
10+
:param c: Divisior number
11+
:return: Returns the result of the operation as a float
12+
"""
13+
return (x**a + y**b) / c
14+
15+
16+
def fn_w_counter() -> (int, dict[str, int]):
17+
18+
caller_name = globals()['__name__']
19+
20+
if not hasattr(fn_w_counter, "call_counter"):
21+
fn_w_counter.call_counter = 0
22+
fn_w_counter.caller_counts = {}
23+
24+
fn_w_counter.call_counter += 1
25+
26+
if caller_name in fn_w_counter.caller_counts:
27+
fn_w_counter.caller_counts[caller_name] += 1
28+
else:
29+
fn_w_counter.caller_counts[caller_name] = 1
30+
31+
return fn_w_counter.call_counter, fn_w_counter.caller_counts

0 commit comments

Comments
 (0)