Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create functions_burak_gulluler.py #183

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Week03/functions_burak_gulluler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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:
"""
a function that takes 5 arguments, 2 of which are optional, and returns a float
:param x: (int) first value
:param y: (int) second value
:param a: (int) first exponent
:param b: (int) second exponent
:param c: (int) divisor
:return: (float) result of the equation
"""
return (x**a + y**b) / c




def fn_w_counter() -> (int, dict[str, int]):
# Get the caller's name
caller = globals()['__name__']

# Initialize counters if they don't exist
if not hasattr(fn_w_counter, 'call_counter'):
fn_w_counter.call_counter = 0
fn_w_counter.caller_counts = {}

# Increment the call counter
fn_w_counter.call_counter += 1

# Increment the caller-specific counter
if caller in fn_w_counter.caller_counts:
fn_w_counter.caller_counts[caller] += 1
else:
fn_w_counter.caller_counts[caller] = 1

# Return the results
return fn_w_counter.call_counter, fn_w_counter.caller_counts