-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create functions_burak_talha_memis.py
- Loading branch information
1 parent
0819173
commit 58845e1
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
fn = lambda arg1 , arg2 : arg1 * arg2 | ||
|
||
def custom_power(x = 0, /, e = 1): | ||
return x ** e | ||
|
||
def custom_equation(x: int = 0, y: int = 0 ,/,a: int = 1,b: int = 1 ,*, c: int = 1) -> (float): | ||
""" | ||
:param x: first integer with default value 0 (positional-only) | ||
:param y: second integer with default value 0 (positional-only) | ||
:param a: third integer with default value 1 (positional-or-keyword) | ||
:param bb: fourth integer with default value 1 (positional-or-keyword) | ||
:param c: fifth integer with default value 1 (keyword-only) | ||
:raises TypeError: if x, y, a, b or c is not an integer | ||
""" | ||
if not isinstance(x, int): | ||
raise TypeError("x must be an integer") | ||
if not isinstance(y, int): | ||
raise TypeError("y must be an integer") | ||
if not isinstance(a, int): | ||
raise TypeError("a must be an integer") | ||
if not isinstance(b, int): | ||
raise TypeError("b must be an integer") | ||
if not isinstance(c, int): | ||
raise TypeError("c must be an integer") | ||
return(x ** a + y ** b) / c | ||
|
||
def fn_w_counter() -> (int, dict[str, int]): | ||
if not hasattr(fn_w_counter, 'counter'): | ||
fn_w_counter.counter = 0 | ||
fn_w_counter.counter += 1 | ||
if not hasattr(fn_w_counter, 'callers'): | ||
fn_w_counter.callers = {f"{__name__}": 1} | ||
else: | ||
fn_w_counter.callers[__name__] += 1 | ||
return fn_w_counter.counter, fn_w_counter.callers | ||
|