Skip to content

Commit e00c651

Browse files
authored
Merge pull request canbula#746 from meldag006/patch-4
Add custom_power and custom_equation functions
2 parents a7d8590 + 523c44d commit e00c651

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎Week04/functions_melda_gungor.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 custom equation.
6+
:param x: first base
7+
:type x: int
8+
:param y: second base
9+
:type y: int
10+
:param a: exponent for x
11+
:type a: int
12+
:param b: exponent for y
13+
:type b: int
14+
:param c: divisor
15+
:type c: int
16+
:return: the result of (x**a + y**b) / c
17+
:rtype: float
18+
"""
19+
20+
return float((x**a + y**b) / c)
21+
22+
23+
def fn_w_counter() -> (int, dict[str,int]):
24+
if not hasattr(fn_w_counter,"total_count"):
25+
fn_w_counter.total_count = 0
26+
fn_w_counter.call_records = {}
27+
28+
caller = __name__
29+
fn_w_counter.total_count += 1
30+
31+
if caller not in fn_w_counter.call_records:
32+
fn_w_counter.call_records[caller] = 1
33+
else:
34+
fn_w_counter.call_records[caller] += 1
35+
36+
return fn_w_counter.total_count, fn_w_counter.call_records
37+
38+
39+

0 commit comments

Comments
 (0)