diff --git a/Week02/types_yagiz_cengiz.py b/Week02/types_yagiz_cengiz.py new file mode 100644 index 00000000..20fa11cf --- /dev/null +++ b/Week02/types_yagiz_cengiz.py @@ -0,0 +1,4 @@ +my_int = 22 +my_float = 7.29 +my_bool = True +my_complex = 5 + 1j diff --git a/Week03/pyramid_yagiz_cengiz.py b/Week03/pyramid_yagiz_cengiz.py new file mode 100644 index 00000000..6b7188f7 --- /dev/null +++ b/Week03/pyramid_yagiz_cengiz.py @@ -0,0 +1,8 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + needed_blocks = 1 + while number_of_blocks >= needed_blocks: + number_of_blocks -= needed_blocks + height += 1 + needed_blocks += 1 + return height diff --git a/Week03/sequences_yagiz_cengiz.py b/Week03/sequences_yagiz_cengiz.py new file mode 100644 index 00000000..ae31fb73 --- /dev/null +++ b/Week03/sequences_yagiz_cengiz.py @@ -0,0 +1,26 @@ +def remove_duplicates(seq: list) -> list: + """ + This function removes duplicates from a list. + """ + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq: list) -> dict: + """ + This function counts the number of occurrences of each item in a list. + """ + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + + +def reverse_dict(d: dict) -> dict: + """ + This function reverses the keys and values of a dictionary. + """ + return {value: key for key, value in d.items()}