-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from CanberkAkar/master
HW:Week-2 types_&sequences_
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
my_list = ["a","b","c","d","e"] | ||
my_tuple = ("canberk","akar",25) | ||
my_set = {"honda","toyota","fiat","fiat"} | ||
my_dict={ | ||
"name" :"The Sopranos", | ||
"director" :"Tim Van Patten", | ||
"year" :1998 | ||
} | ||
|
||
def remove_duplicates(list): | ||
dub=[] | ||
for item in list: | ||
if item not in dub: | ||
dub.append(item) | ||
return dub | ||
|
||
def list_counts(list): | ||
dictionary = {} | ||
for item in list: | ||
if item in dictionary: | ||
dictionary[item] += 1 | ||
else: | ||
dictionary[item] = 1 | ||
return dictionary | ||
|
||
def reverse_dict(dictionary): | ||
dict = {} | ||
for item in dictionary.items(): | ||
dict[item[1]] = item[0] | ||
return dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 2 | ||
my_float = 5.9 | ||
my_bool = False | ||
my_complex = 8 + 8j |