Skip to content

Commit f27b8e5

Browse files
authored
Merge pull request #733 from eminbadur/master
Create sequences_emin_badur.py
2 parents 7c31fe2 + 5a9dfc3 commit f27b8e5

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

Week01/info_emin_badur.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
student_id = "210316031"
2+
full_name = "Emin Badur"

Week02/types_emin_badur.py

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

Week03/pyramid_emin_badur.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def calculate_pyramid_height(number_of_blocks):
2+
height = 1
3+
4+
if number_of_blocks <= 0 :
5+
raise ValueError("Number of blocks must be positive ")
6+
7+
while number_of_blocks > height + 1 :
8+
height += 1
9+
number_of_blocks -= height
10+
11+
return height

Week03/sequences_emin_badur.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def remove_duplicates(seq: list) -> list :
2+
#This function remove duplicates from list. But we could use the set method to same purpose too.
3+
current_index = 0
4+
while current_index < len(seq) - 1 :
5+
if seq[current_index] == seq[current_index + 1]:
6+
del seq[current_index + 1]
7+
else :
8+
current_index += 1
9+
return seq
10+
11+
def list_counts(seq: list) -> dict:
12+
return {item: seq.count(item) for item in seq}
13+
14+
def reverse_dict(d: dict) -> dict:
15+
new_dict = {}
16+
for key, value in d.items():
17+
new_dict[value] = key
18+
return new_dict
19+
20+
21+
22+
23+
24+

0 commit comments

Comments
 (0)