Skip to content

Commit 92b0100

Browse files
authored
Create functions_mert_can_fidan.py
I created custom_power and custom_equation for get result of desired equations and created fn_w_counter function for get desired informations.
1 parent a35cc10 commit 92b0100

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Week03/functions_mert_can_fidan.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
custom_power = lambda x = 0, /, e = 1: x**e
2+
3+
4+
def custom_equation(x: int = 0,
5+
y: int = 0,
6+
/,
7+
a: int = 1,
8+
b: int = 1,
9+
*,
10+
c: int = 1) -> float:
11+
"""
12+
This fuction firstly calculates
13+
the a power of the number x and
14+
the b power of the number y after that
15+
adds up calculated numbers and
16+
divedes the result by c.
17+
18+
:param x: The first number, positional-only and default value 0
19+
:type x: int
20+
:param y: The second number, positional-only and default value 0
21+
:type y: int
22+
:param a: The third number, positional-or-keyword and default value 1
23+
:type a: int
24+
:param b: The fourth number, positional-or-keyword and default value 1
25+
:type b: int
26+
:param c: The fifth number, positional-or-keyword and default value 1
27+
:type c: int
28+
:return: result of equation
29+
:rtype: float
30+
"""
31+
return (x**a + y**b)/c
32+
33+
34+
def fn_w_counter() -> (int, dict[str, int]):
35+
if not hasattr(fn_w_counter, "total_calls"):
36+
fn_w_counter.total_calls = 0
37+
fn_w_counter.callers_information = {}
38+
39+
caller_name = __name__
40+
fn_w_counter.total_calls += 1
41+
42+
if caller_name in fn_w_counter.callers_information:
43+
fn_w_counter.callers_information[caller_name] += 1
44+
else:
45+
fn_w_counter.callers_information[caller_name] = 1
46+
47+
return fn_w_counter.total_calls, fn_w_counter.callers_information

0 commit comments

Comments
 (0)