From adc3622afcc357a1f1afdce6b0edace1fcb58bf3 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:24:49 +0300 Subject: [PATCH 1/9] Add files via upload --- Week01/info_halilturker_eren.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Week01/info_halilturker_eren.py diff --git a/Week01/info_halilturker_eren.py b/Week01/info_halilturker_eren.py new file mode 100644 index 00000000..584dfd30 --- /dev/null +++ b/Week01/info_halilturker_eren.py @@ -0,0 +1,2 @@ +student_id="200316041" +full_name="Halil Türker Eren" \ No newline at end of file From 4ef8beea41baa2bec0859caa1d8a475565f5a683 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:26:53 +0300 Subject: [PATCH 2/9] Add files via upload --- Week02/types_halilturker_eren.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Week02/types_halilturker_eren.py diff --git a/Week02/types_halilturker_eren.py b/Week02/types_halilturker_eren.py new file mode 100644 index 00000000..9282c20a --- /dev/null +++ b/Week02/types_halilturker_eren.py @@ -0,0 +1,4 @@ +my_int = 7 +my_float = 3.69 +my_bool = False +my_complex = 9 + 2j \ No newline at end of file From 208f3d98df17d94e3a4b4614ebf8605e0fbce199 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:32:26 +0300 Subject: [PATCH 3/9] Add files via upload --- Week03/pyramid_halilturker_eren.py | 5 +++++ Week03/sequences_halilturker_eren.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Week03/pyramid_halilturker_eren.py create mode 100644 Week03/sequences_halilturker_eren.py diff --git a/Week03/pyramid_halilturker_eren.py b/Week03/pyramid_halilturker_eren.py new file mode 100644 index 00000000..b372afba --- /dev/null +++ b/Week03/pyramid_halilturker_eren.py @@ -0,0 +1,5 @@ +def calculate_pyramid_height(numOfBlocks): + height = 0 + while ((height * (height + 1))/2) <= numOfBlocks: + height+=1 + return height - 1 \ No newline at end of file diff --git a/Week03/sequences_halilturker_eren.py b/Week03/sequences_halilturker_eren.py new file mode 100644 index 00000000..0ac754af --- /dev/null +++ b/Week03/sequences_halilturker_eren.py @@ -0,0 +1,24 @@ +def remove_duplicates(seq: list) -> list: + + return list(set(seq)) + + +def list_counts(seq: list) -> dict: + + count = {} + + for i in seq: + count[i] = seq.count(i) + + return count + + + +def reverse_dict(d: dict) -> dict: + + reversed = {} + + for key, value in d.items(): + reversed[value] = key + + return reversed \ No newline at end of file From e9238364cd85f041851ddd57ea9dc3a1b88562f9 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:41:11 +0300 Subject: [PATCH 4/9] Add files via upload --- Week04/decorators_halilturker_eren.py | 22 ++++++++++++++++++++++ Week04/functions_halilturker_eren.py | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Week04/decorators_halilturker_eren.py create mode 100644 Week04/functions_halilturker_eren.py diff --git a/Week04/decorators_halilturker_eren.py b/Week04/decorators_halilturker_eren.py new file mode 100644 index 00000000..53746408 --- /dev/null +++ b/Week04/decorators_halilturker_eren.py @@ -0,0 +1,22 @@ +import time +import tracemalloc + + +def performance(func): + setattr(performance, 'counter', 0) + setattr(performance, 'total_time', 0.0) + setattr(performance, 'total_mem', 0.0) + + def wrapper(*args, **kwargs): + tracemalloc.start() + start_time = time.time() + result = func(*args, **kwargs) + end_time = time.time() + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + setattr(performance, 'counter', getattr(performance, 'counter') + 1) + setattr(performance, 'total_time', getattr(performance, 'total_time') + end_time - start_time) + setattr(performance, 'total_mem', getattr(performance, 'total_mem') + peak) + return result + + return wrapper \ No newline at end of file diff --git a/Week04/functions_halilturker_eren.py b/Week04/functions_halilturker_eren.py new file mode 100644 index 00000000..9bc110b0 --- /dev/null +++ b/Week04/functions_halilturker_eren.py @@ -0,0 +1,23 @@ +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: + + return (x ** a + y ** b) / c + + +def fn_w_counter() -> (int, dict[str, int]): + + if not hasattr(fn_w_counter, "count"): + setattr(fn_w_counter, "count", 0) + setattr(fn_w_counter, "caller_dict", {}) + + fn_w_counter.count += 1 + caller = __name__ + + if caller not in fn_w_counter.caller_dict: + fn_w_counter.caller_dict[caller] = 0 + + fn_w_counter.caller_dict[caller] += 1 + + return (int(fn_w_counter.count), dict(fn_w_counter.caller_dict)) \ No newline at end of file From 6f1927a24733760f2fcb82fc711029f225d2a299 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:51:57 +0300 Subject: [PATCH 5/9] Delete Week02/types_halilturker_eren.py --- Week02/types_halilturker_eren.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 Week02/types_halilturker_eren.py diff --git a/Week02/types_halilturker_eren.py b/Week02/types_halilturker_eren.py deleted file mode 100644 index 9282c20a..00000000 --- a/Week02/types_halilturker_eren.py +++ /dev/null @@ -1,4 +0,0 @@ -my_int = 7 -my_float = 3.69 -my_bool = False -my_complex = 9 + 2j \ No newline at end of file From a22e2ea0806e8a55098ee493d8625f646530ec71 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:52:22 +0300 Subject: [PATCH 6/9] Delete Week03/pyramid_halilturker_eren.py --- Week03/pyramid_halilturker_eren.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Week03/pyramid_halilturker_eren.py diff --git a/Week03/pyramid_halilturker_eren.py b/Week03/pyramid_halilturker_eren.py deleted file mode 100644 index b372afba..00000000 --- a/Week03/pyramid_halilturker_eren.py +++ /dev/null @@ -1,5 +0,0 @@ -def calculate_pyramid_height(numOfBlocks): - height = 0 - while ((height * (height + 1))/2) <= numOfBlocks: - height+=1 - return height - 1 \ No newline at end of file From bc765a5a6cf82d3e6b95e5180722803c6575f2a2 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:52:34 +0300 Subject: [PATCH 7/9] Delete Week03/sequences_halilturker_eren.py --- Week03/sequences_halilturker_eren.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Week03/sequences_halilturker_eren.py diff --git a/Week03/sequences_halilturker_eren.py b/Week03/sequences_halilturker_eren.py deleted file mode 100644 index 0ac754af..00000000 --- a/Week03/sequences_halilturker_eren.py +++ /dev/null @@ -1,24 +0,0 @@ -def remove_duplicates(seq: list) -> list: - - return list(set(seq)) - - -def list_counts(seq: list) -> dict: - - count = {} - - for i in seq: - count[i] = seq.count(i) - - return count - - - -def reverse_dict(d: dict) -> dict: - - reversed = {} - - for key, value in d.items(): - reversed[value] = key - - return reversed \ No newline at end of file From 945e3653db51c69420db01b43acff7635295b333 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:52:47 +0300 Subject: [PATCH 8/9] Delete Week04/decorators_halilturker_eren.py --- Week04/decorators_halilturker_eren.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Week04/decorators_halilturker_eren.py diff --git a/Week04/decorators_halilturker_eren.py b/Week04/decorators_halilturker_eren.py deleted file mode 100644 index 53746408..00000000 --- a/Week04/decorators_halilturker_eren.py +++ /dev/null @@ -1,22 +0,0 @@ -import time -import tracemalloc - - -def performance(func): - setattr(performance, 'counter', 0) - setattr(performance, 'total_time', 0.0) - setattr(performance, 'total_mem', 0.0) - - def wrapper(*args, **kwargs): - tracemalloc.start() - start_time = time.time() - result = func(*args, **kwargs) - end_time = time.time() - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - setattr(performance, 'counter', getattr(performance, 'counter') + 1) - setattr(performance, 'total_time', getattr(performance, 'total_time') + end_time - start_time) - setattr(performance, 'total_mem', getattr(performance, 'total_mem') + peak) - return result - - return wrapper \ No newline at end of file From dac3e85b4832ae22d162aab54879656cb4bfce33 Mon Sep 17 00:00:00 2001 From: turkereren <74651832+turkereren@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:52:55 +0300 Subject: [PATCH 9/9] Delete Week04/functions_halilturker_eren.py --- Week04/functions_halilturker_eren.py | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 Week04/functions_halilturker_eren.py diff --git a/Week04/functions_halilturker_eren.py b/Week04/functions_halilturker_eren.py deleted file mode 100644 index 9bc110b0..00000000 --- a/Week04/functions_halilturker_eren.py +++ /dev/null @@ -1,23 +0,0 @@ -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: - - return (x ** a + y ** b) / c - - -def fn_w_counter() -> (int, dict[str, int]): - - if not hasattr(fn_w_counter, "count"): - setattr(fn_w_counter, "count", 0) - setattr(fn_w_counter, "caller_dict", {}) - - fn_w_counter.count += 1 - caller = __name__ - - if caller not in fn_w_counter.caller_dict: - fn_w_counter.caller_dict[caller] = 0 - - fn_w_counter.caller_dict[caller] += 1 - - return (int(fn_w_counter.count), dict(fn_w_counter.caller_dict)) \ No newline at end of file