Skip to content

Commit

Permalink
Create functions_mert_can_fidan.py
Browse files Browse the repository at this point in the history
I created custom_power and custom_equation for get result of desired equations and created fn_w_counter function for get desired informations.
  • Loading branch information
usrmertc authored Mar 14, 2024
1 parent a35cc10 commit 92b0100
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Week03/functions_mert_can_fidan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
custom_power = lambda x = 0, /, e = 1: x**e


def custom_equation(x: int = 0,
y: int = 0,
/,
a: int = 1,
b: int = 1,
*,
c: int = 1) -> float:
"""
This fuction firstly calculates
the a power of the number x and
the b power of the number y after that
adds up calculated numbers and
divedes the result by c.
:param x: The first number, positional-only and default value 0
:type x: int
:param y: The second number, positional-only and default value 0
:type y: int
:param a: The third number, positional-or-keyword and default value 1
:type a: int
:param b: The fourth number, positional-or-keyword and default value 1
:type b: int
:param c: The fifth number, positional-or-keyword and default value 1
:type c: int
:return: result of equation
:rtype: float
"""
return (x**a + y**b)/c


def fn_w_counter() -> (int, dict[str, int]):
if not hasattr(fn_w_counter, "total_calls"):
fn_w_counter.total_calls = 0
fn_w_counter.callers_information = {}

caller_name = __name__
fn_w_counter.total_calls += 1

if caller_name in fn_w_counter.callers_information:
fn_w_counter.callers_information[caller_name] += 1
else:
fn_w_counter.callers_information[caller_name] = 1

return fn_w_counter.total_calls, fn_w_counter.callers_information

0 comments on commit 92b0100

Please sign in to comment.