Skip to content

Create types_firat_kaya_ozgenc.py #100

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 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Binary file added Week02/__pycache__/other_file.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/sequences_bahri_un.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_ali_duman.cpython-39.pyc
Binary file not shown.
Binary file added Week02/__pycache__/types_bahri_un.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_beyza_sungar.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_emre_bicer.cpython-39.pyc
Binary file not shown.
Binary file added Week02/__pycache__/types_eren_yuksel.cpython-39.pyc
Binary file not shown.
Binary file added Week02/__pycache__/types_esra_basoglu.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_melisa_sahin.cpython-39.pyc
Binary file not shown.
Binary file added Week02/__pycache__/types_melisa_uyar.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_mine_altug.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Week02/__pycache__/types_umit_unal.cpython-39.pyc
Binary file not shown.
Binary file added Week02/__pycache__/types_yavuz_selim.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions Week02/sequences_firat_kaya_ozgenc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
my_list = [1, 2, 3, 3, 4, 5, 5, 5, 6]
my_tuple = (1, 2, 3, 4, 5)
my_set = {1, 2, 3, 4, 5}
my_dict = {'a': 1, 'b': 2, 'c': 3}

def remove_duplicates(seq):
return list(set(seq))

def list_counts(seq):
counts = {}
for item in seq:
counts[item] = counts.get(item, 0) + 1
return counts

def reverse_dict(d):
return {v: k for k, v in d.items()}
58 changes: 58 additions & 0 deletions Week02/test_sequences.py.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import os


files = [f for f in os.listdir(os.path.dirname(__file__)) if f.startswith("sequences")]
for f in files:
exec("import " + f[:-3] + " as " + f[:-3])


def test_names():
for f in files:
assert "my_list" in dir(eval(f[:-3])), "my_list is not defined in " + f[:-3]
assert "my_tuple" in dir(eval(f[:-3])), "my_tuple is not defined in " + f[:-3]
assert "my_set" in dir(eval(f[:-3])), "my_set is not defined in " + f[:-3]
assert "my_dict" in dir(eval(f[:-3])), "my_dict is not defined in " + f[:-3]


def test_types():
for f in files:
assert isinstance(eval(f[:-3]).my_list, list), "my_list is not a list in " + f[:-3]
assert isinstance(eval(f[:-3]).my_tuple, tuple), "my_tuple is not a tuple in " + f[:-3]
assert isinstance(eval(f[:-3]).my_set, set), "my_set is not a set in " + f[:-3]
assert isinstance(eval(f[:-3]).my_dict, dict), "my_dict is not a dict in " + f[:-3]


def test_remove_duplicates():
for f in files:
assert eval(f[:-3]).remove_duplicates([1, 2, 3, 3, 4, 5, 5, 5, 6]) == [1, 2, 3, 4, 5, 6], \
"remove_duplicates is not working in " + f[:-3]
assert eval(f[:-3]).remove_duplicates([1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6], \
"remove_duplicates is not working in " + f[:-3]
assert eval(f[:-3]).remove_duplicates([1, 1, 1, 1, 1, 1]) == [1], \
"remove_duplicates is not working in " + f[:-3]
assert eval(f[:-3]).remove_duplicates([]) == [], \
"remove_duplicates is not working in " + f[:-3]


def test_list_counts():
for f in files:
assert eval(f[:-3]).list_counts([1, 2, 3, 3, 4, 5, 5, 5, 6]) == {1: 1, 2: 1, 3: 2, 4: 1, 5: 3, 6: 1}, \
"list_counts is not working in " + f[:-3]
assert eval(f[:-3]).list_counts([1, 2, 3, 4, 5, 6]) == {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1}, \
"list_counts is not working in " + f[:-3]
assert eval(f[:-3]).list_counts([1, 1, 1, 1, 1, 1]) == {1: 6}, \
"list_counts is not working in " + f[:-3]
assert eval(f[:-3]).list_counts([]) == {}, \
"list_counts is not working in " + f[:-3]


def test_reverse_dict():
for f in files:
assert eval(f[:-3]).reverse_dict({1: 1, 2: 2, 3: 3}) == {1: 1, 2: 2, 3: 3}, \
"reverse_dict is not working in " + f[:-3]
assert eval(f[:-3]).reverse_dict({1: 2, 2: 3, 3: 4}) == {2: 1, 3: 2, 4: 3}, \
"reverse_dict is not working in " + f[:-3]
assert eval(f[:-3]).reverse_dict({1: 1, 2: 1, 3: 1}) == {1: 3}, \
"reverse_dict is not working in " + f[:-3]
assert eval(f[:-3]).reverse_dict({}) == {}, \
"reverse_dict is not working in " + f[:-3]
4 changes: 4 additions & 0 deletions Week02/types_firat_kaya_ozgenc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
my_int = 6
my_float = 6.6
my_bool = True
my_complex = 6+6j