Skip to content

Create sequences_zehra_karatas.py #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Week02/sequences_zehra_karatas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
my_list = [1, 2, 3, 3, 1, 1, 4]
my_tuple = (2, 4, 4, 7, 9)
my_set = {3, 10, 12, 15, 19}
my_dict = {
"first_exam" : 67,
"second_exam" : 89,
"third_exam" : 58
}


def remove_duplicates(my_list):
update_list = list(set(my_list))
return update_list


def list_counts(my_list):
counts = {} #empty dict
for item in my_list:
if item in counts:
counts[item] += 1
else:
counts[item] = 1
return counts


def reverse_dict(my_dict):
reverse_dict = {}
for key, value in my_dict.items():
reverse_dict[value] = key
return reverse_dict


result_duplicates = remove_duplicates(my_list)
result_counts= list_counts(my_list)
result_reverse = reverse_dict(my_dict)

print(result_duplicates)
print(result_counts)
print(result_reverse)