Skip to content

Commit bdfcfb4

Browse files
authored
Merge pull request #662 from yagizcngz/master
Week02_Week03_homework
2 parents 9a83123 + 39cac7b commit bdfcfb4

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎Week02/types_yagiz_cengiz.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
my_int = 22
2+
my_float = 7.29
3+
my_bool = True
4+
my_complex = 5 + 1j

‎Week03/pyramid_yagiz_cengiz.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
height = 0
3+
needed_blocks = 1
4+
while number_of_blocks >= needed_blocks:
5+
number_of_blocks -= needed_blocks
6+
height += 1
7+
needed_blocks += 1
8+
return height

‎Week03/sequences_yagiz_cengiz.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def remove_duplicates(seq: list) -> list:
2+
"""
3+
This function removes duplicates from a list.
4+
"""
5+
result = []
6+
for item in seq:
7+
if item not in result:
8+
result.append(item)
9+
return result
10+
11+
12+
def list_counts(seq: list) -> dict:
13+
"""
14+
This function counts the number of occurrences of each item in a list.
15+
"""
16+
counts = {}
17+
for item in seq:
18+
counts[item] = counts.get(item, 0) + 1
19+
return counts
20+
21+
22+
def reverse_dict(d: dict) -> dict:
23+
"""
24+
This function reverses the keys and values of a dictionary.
25+
"""
26+
return {value: key for key, value in d.items()}

0 commit comments

Comments
 (0)