diff --git a/Week02/types_tarik_bozgan.py b/Week02/types_tarik_bozgan.py new file mode 100644 index 0000000..2222af0 --- /dev/null +++ b/Week02/types_tarik_bozgan.py @@ -0,0 +1,4 @@ +my_int = 9 +my_float = 9.7 +my_bool = True +my_complex = 6j \ No newline at end of file diff --git a/Week03/pyramid_tarik_bozgan.py b/Week03/pyramid_tarik_bozgan.py new file mode 100644 index 0000000..fa76264 --- /dev/null +++ b/Week03/pyramid_tarik_bozgan.py @@ -0,0 +1,7 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + while(number_of_blocks >= 0): + height += 1 + number_of_blocks -= height + return height - 1 + diff --git a/Week03/sequences_tarik_bozgan.py b/Week03/sequences_tarik_bozgan.py new file mode 100644 index 0000000..cbf9233 --- /dev/null +++ b/Week03/sequences_tarik_bozgan.py @@ -0,0 +1,25 @@ +def remove_duplicates(list): + seen = set() + result = [] + for item in list: + if item not in seen: + seen.add(item) + result.append(item) + return result + + +def list_counts(list): + counts = {} + for item in list: + if item in counts: + counts[item] = counts[item] + 1 + else: + counts[item] = 1 + return counts + + +def reverse_dict(dict): + reversed_dict = {} + for key, value in dict.items(): + reversed_dict[value] = key + return reversed_dict \ No newline at end of file diff --git a/Week04/arrays_tarik_bozgan.py b/Week04/arrays_tarik_bozgan.py new file mode 100644 index 0000000..370f241 --- /dev/null +++ b/Week04/arrays_tarik_bozgan.py @@ -0,0 +1,16 @@ +import numpy as np +def replace_center_with_minus_one(d, n, m): + if m > n or d <= 0 or n < 0 or m < 0: + raise ValueError + + if d == 1: + array = np.random.randint(0, 10, size=(n, n)) + else: + array = np.random.randint(10**(d-1), 10**d, size=(n, n)) + + border_start = (n - m) // 2 + border_end = border_start + m + + array[border_start:border_end, border_start:border_end] = -1 + + return array \ No newline at end of file