Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Week01/info_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
student_id = "220316056"
full_name = "İbrahim Özel"
4 changes: 4 additions & 0 deletions Week02/types_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
my_int = 32
my_float = 3.32
my_bool = True
my_complex = 3 + 2j
9 changes: 9 additions & 0 deletions Week03/pyramid_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def calculate_pyramid_height(number_of_blocks):
height = 0
blocks = 0

while blocks + height + 1 <= number_of_blocks:
height += 1
blocks += height

return height
20 changes: 20 additions & 0 deletions Week03/sequences_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def remove_duplicates(seq: list) -> list:

result = []
for item in seq:
if item not in result:
result.append(item)
return result


def list_counts(seq: list) -> dict:

counts = {}
for item in seq:
counts[item] = counts.get(item, 0) + 1
return counts


def reverse_dict(d: dict) -> dict:

return {value: key for key, value in d.items()}
31 changes: 31 additions & 0 deletions Week04/decorators_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import time
import tracemalloc

def performance(func):

def wrapper(*args, **kwargs):

tracemalloc.start()
start = time.perf_counter()
start_mem = tracemalloc.get_traced_memory()[0]
tracemalloc.reset_peak()

try:
result = func(*args, **kwargs)

finally:
end = time.perf_counter()
current, peak = tracemalloc.get_traced_memory()

performance.counter += 1
performance.total_time += end - start
performance.total_mem += peak - start_mem

tracemalloc.stop()

return result
return wrapper

performance.counter = 0
performance.total_time = 0
performance.total_mem = 0
27 changes: 27 additions & 0 deletions Week04/functions_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 function does arithmetic opearations.

:param1: first number to be exponantiated
:param2: second number to be exponantiated
:param3: power of the first number
:param4: power of the second number
:param5: divisor of sum of exponantiated numbers

:return: division the sum of exponantiated numbers
"""
return (x**a + y**b) / c

call_counter = 0
caller_dict = {}
def fn_w_counter() -> (int, dict[str, int]):
caller = __name__
global call_counter
call_counter += 1
if caller in caller_dict:
caller_dict[caller] += 1
else:
caller_dict[caller] = 1
return call_counter, caller_dict
30 changes: 30 additions & 0 deletions Week05/emails_ibrahim_özel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Emails(list):
def __init__(self, email_list):
checked = self.validate(email_list)
super().__init__(checked)
self.data = checked

def validate(self, email_list):
result = []
for item in email_list:
if type(item) is not str:
raise ValueError("Only strings are allowed")
if item.count("@") != 1:
raise ValueError("Invalid email: " + item)
user, domain = item.split("@")
if user == "" or "." not in domain:
raise ValueError("Invalid email: " + item)
if domain.startswith(".") or domain.endswith("."):
raise ValueError("Invalid email: " + item)
if item not in result:
result.append(item)
return result

def __repr__(self):
return "Emails(" + str(list(self)) + ")"

def __str__(self):
text = "Emails:\n"
for i, mail in enumerate(self, start=1):
text += f"{i}. {mail}\n"
return text