From e54491f19404aa23500362723cbc3cc39e1d1921 Mon Sep 17 00:00:00 2001 From: Ilya Tishin Date: Tue, 25 Aug 2020 16:48:36 -0700 Subject: [PATCH 1/5] add homework 5 --- lesson_5/__init__.py | 0 lesson_5/homework_5_1.py | 40 ++++++++++++++++++++++ tests/{homework_4_1.py => homework_5_1.py} | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 lesson_5/__init__.py create mode 100644 lesson_5/homework_5_1.py rename tests/{homework_4_1.py => homework_5_1.py} (98%) diff --git a/lesson_5/__init__.py b/lesson_5/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lesson_5/homework_5_1.py b/lesson_5/homework_5_1.py new file mode 100644 index 0000000..bf2e865 --- /dev/null +++ b/lesson_5/homework_5_1.py @@ -0,0 +1,40 @@ +# FUNCTIONS + +# Difference +# Write a function, which will calculate the difference of these two numbers + +def difference(num_1, num_2): + pass + + +# Division +# Write a function, which will divide these two numbers + +def division(num_1, num_2): + pass + + +# Function gets random number. If this number is more than ten, return the difference between 100 and this number, +# otherwise return this number multiplied by 10 + +def function_1(number): + pass + + +# Your function temerature_convertor gets the temperature in Fahrenheit, convert it to Celsius and return. +# Formula (32°F − 32) × 5/9 = 0°C + +def temerature_convertor(fahrenheit_degree): + pass + + +# Taxi Fare +# In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters travelled. +# Write a function that takes the distance travelled (in kilometers) as its only parameter and returns the total fare +# as its only result rounded by 2 digits. Write a program that demonstrates the function. + +def taxi_fare(distance): + pass + +# examples of usage: +# taxi_fare(10) #21.86 \ No newline at end of file diff --git a/tests/homework_4_1.py b/tests/homework_5_1.py similarity index 98% rename from tests/homework_4_1.py rename to tests/homework_5_1.py index 57f6200..78eaa72 100644 --- a/tests/homework_4_1.py +++ b/tests/homework_5_1.py @@ -58,7 +58,7 @@ # THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS -from lesson_4.homework_4_1 import difference, division, function_1, temerature_convertor, taxi_fare +from lesson_5.homework_5_1 import difference, division, function_1, temerature_convertor, taxi_fare import pytest From 1adffe4de721d01de1cfcb251218b81c5dca6242 Mon Sep 17 00:00:00 2001 From: Ilya Tishin Date: Thu, 27 Aug 2020 16:24:32 -0700 Subject: [PATCH 2/5] add homework 6 --- lesson_6/__init__.py | 0 lesson_6/homework_6_1.py | 87 +++++++++++++++++++ lesson_6/homework_6_2.py | 163 +++++++++++++++++++++++++++++++++++ tests/homework_6_1.py | 180 +++++++++++++++++++++++++++++++++++++++ tests/homework_6_2.py | 178 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 608 insertions(+) create mode 100644 lesson_6/__init__.py create mode 100644 lesson_6/homework_6_1.py create mode 100644 lesson_6/homework_6_2.py create mode 100644 tests/homework_6_1.py create mode 100644 tests/homework_6_2.py diff --git a/lesson_6/__init__.py b/lesson_6/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lesson_6/homework_6_1.py b/lesson_6/homework_6_1.py new file mode 100644 index 0000000..77b814a --- /dev/null +++ b/lesson_6/homework_6_1.py @@ -0,0 +1,87 @@ +# You are given a list in list_1 variable, write a swap_first_last function to return a new list with +# the first and the last elements of the list swapped. +list_1 = [1, 'asdasd', True, 2, False, 4, 'Hello world', None, range(1, 11), 100] + +def swap_first_last(array_1): + pass + + +# You are given a list in list_2 variable, write a reverse_list function which creates a new list in reversed order. +list_2 = [1, 'asdasd', True, 2, False, 4, 'Hello world', None, range(1, 11), 100] + +def reverse_list(array_2): + pass + + +# Create a list which contains only number items and save it to the list_3 variable. Then write multiply_list_items +# function to multiply all the items in a list. +list_3 = None + +def multiply_list_items(array_3): + pass + + +# Create a list which contains only number items and save it to the list_4 variable. Then write a smallest_item_list +# function to get the smallest number from a list +list_4 = [10, 2, 5, 5, 0] + +def smallest_item_list(array_4): + pass + + +# Given a list in list_5 variable, write a remove_duplicates_list function to remove duplicates from a list. +list_5 = [1, 2, 3, 1, 1, 1, 2, 3, 4, 'hello', 1, 2, 3, 4, 'hello', 'hello', 1] + +def remove_duplicates_list(array_5): + pass + + +# You are given a list in list_6 variable.Enter an integer number and save it to number_1 variable, +# write a longer_words_list function which will return the list of words that are longer than number_1 +# from a given list of words. +number_1 = 5 +list_6 = ['On', 'it', 'differed', 'repeated', 'wandered', 'required', 'in.', 'Then', 'girl', 'neat', 'why', 'yet', + 'knew', 'rose', 'spot.', 'Moreover', 'property', 'we', 'he', 'kindness', 'greatest', 'be', 'oh', 'striking', + 'laughter.', 'In', 'me', 'he', 'at', 'collecting', 'affronting', 'principles', 'apartments.', 'Has', 'visitor', + 'law', 'attacks', 'pretend', 'you', 'calling', 'own', 'excited', 'painted.', 'Contented', 'attending', + 'smallness', 'it', 'oh', 'ye', 'unwilling.', 'Turned', 'favour', 'man', 'two', 'but', 'lovers.', 'Suffer', + 'should', 'if', 'waited', 'common', 'person', 'little', 'oh.', 'Improved', 'civility', 'graceful', 'few', + 'smallest', 'screened', 'settling.', 'Likely', 'active', 'her', 'warmly', 'has.'] + +def longer_words_list(array_6, number1): + pass + + +# Given two lists in list_7 and list_8 variables. Write a function find_item_lists that takes two lists and returns +# True if they have at least one common member. +list_7 = [1, 2, 3, 1, 1, 1, 2, 3, 4, 'hello', 1, 2, 3, 4, 'hello', 'hello', 1] +list_8 = ['asdasd', True, 8, False, 94, 'Hello world', None, range(1, 11), 100, 1] + +def find_item_lists(array_7, array_8): + pass + + +# You are given a list in list_9 variable. Write a function string_to_list to convert a list of +# characters into a string. +list_9 = ['I', ' ', 'l', 'i', 'k', 'e', ' ', 'P', 'y', 't', 'h', 'o', 'n'] + +def list_to_string(list9): + pass + + +# Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number of +# occurrences of x in the given list +list_10 = [1, 2, 3, 1, 1, 1, 2, 3, 4] +number_2 = 3 + +def count_items_list(array_10, number2): + pass + + +# Given a list of numbers, write a function even_items_list to return new list which include all even numbers in +# given list. +list_11 = [1, 2, 3, 1, 1, 1, 2, 3, 4] + +def even_items_list(array_11): + pass + diff --git a/lesson_6/homework_6_2.py b/lesson_6/homework_6_2.py new file mode 100644 index 0000000..6d301ac --- /dev/null +++ b/lesson_6/homework_6_2.py @@ -0,0 +1,163 @@ +# Enter a country and save it to variable your_choice_country. Write find_index_by_value function which will check +# if the tuple countries contains a country of your choice. If your_choice_country is in the tuple, return its +# index, otherwise return a -1 value + +countries = ('USA', 'Canada', 'United Kingdom', 'Mexico', 'Brazil', 'Argentina', 'Chili', 'South Africa', 'Egypt', + 'Morocco', 'India', 'China', 'Ukraine', 'Spain', 'France', 'Russia') +your_choice_country = None + +def find_index_by_value(value, tuple1): + pass + + +# Change the previous exercise. Enter a random number and save it to variable your_choice_number. Write +# find_value_by_index function which will check if the tuple countries contains a country with this index. +# If there is a value with this index your_choice_number in the tuple, return this value, +# otherwise return a 'No such index' text + +your_choice_number = None + +def find_value_by_index(index, tuple1): + pass + + +# Enter a pair of values in variables new_team_name, new_team_city. Then write add_your_own_team function +# to add them to nhl_hockey_teams dictionary, where the name will be the key. + +new_team_name = None +new_team_city = None + +nhl_hockey_teams = { + "Canadiens": "Montreal", + "Maple Leafs": "Toronto", + "Red Wings": "Detroit", + "Bruins": "Boston", + "Blackhawks": "Chicago", + "Oilers": "Edmonton", + "Penguins": "Pittsburgh", + "Islanders": "New York", + "Rangers": "New York", + "Devils": "New Jersey", + "Avalanche": "Colorado", + "Kings": "Los Angeles", + "Flyers": "Philadelphia", + "Ducks": "Anaheim", + "Flames": "Calgary", + "Hurricanes": "Carolina", + "Stars": "Dallas", + "Blues": "St. Louis", + "Lightning": "Tampa Bay", + "Capitals": "Washington" +} + +def add_your_own_team(team_name, team_city): + pass + + +# Create two dictionaries in dict_1, dict_2 variables. Write a join_dicts function to concatenate the following +# dictionaries to create a new one. + +dict_1 = None +dict_2 = None + +def join_dicts(dict1, dict2): + pass + + +# # Enter a random number and save it to number_1 variable. Then write create_numbers_dict function to generate +# a dictionary that contains items with keys from 1 to number_1 and values in format "x": "x**2". + +number_1 = None + +def create_numbers_dict(number1): + pass + + +# Write sum_up_hockey_cups functions to sum all values in a dictionary dict_3. + +dict_3 = { + "Montreal Canadiens": 24, + "Toronto Maple Leafs": 13, + "Detroit Red Wings": 11, + "Boston Bruins": 6, + "Chicago Blackhawks": 6, + "Edmonton Oilers": 5, + "Pittsburgh Penguins": 5, + "New York Islanders": 4, + "New York Rangers": 4, + "New Jersey Devils": 3, + "Colorado Avalanche": 2, + "Los Angeles Kings": 2, + "Philadelphia Flyers": 2, + "Anaheim Ducks": 1, + "Calgary Flames": 1, + "Carolina Hurricanes": 1, + "Dallas Stars": 1, + "St. Louis Blues": 1, + "Tampa Bay Lightning": 1, + "Washington Capitals": 1 +} + +def sum_up_hockey_cups(teams_dict): + pass + + +# Write remove_item_by_key function to remove a key True from dict_4 dictionary. + +dict_4 = { + "a": 231, + "b": 'hello', + True: False, + 42: 'answer' +} + +def remove_item_by_key(dict1): + pass + + +# Write find_min_max function to get the maximum and minimum value in dict_5 dictionary. Return the answer in format +# { +# "min": 111, +# "max": 222 +# } + +dict_5 = { + "Cyprus": 1207359, + "Czechia": 10708981, + "Democratic Republic of the Congo": 89561403, + "Denmark": 5792202, + "Djibouti": 988000, + "Dominica": 71986, + "Dominican Republic": 10847910, + "Ecuador": 17643054, + "Egypt": 102334404, + "El Salvador": 6486205, + "Equatorial Guinea": 1402985, + "Eritrea": 3546421, + "Estonia": 1326535, + "Eswatini": 1160164, + "Ethiopia": 114963588, + "Fiji": 896445, +} + +def find_min_max(dict1): + pass + + +# Write remove_duplicates functions to remove duplicates from dictionary dict_6. + +dict_6 = { + "Lessie": "collie", + "Marlie": "labrador", + "Spike": "boxer", + "Buddy": "labrador", + "Milo": "labrador", + "Archie": "corgi", + "Tobby": "pit bull", + "Jack": "poodle", + "Lucy": "german shepherd", + "Bailey": "labrador" +} + +def remove_duplicates(dict1): + pass diff --git a/tests/homework_6_1.py b/tests/homework_6_1.py new file mode 100644 index 0000000..5c5500e --- /dev/null +++ b/tests/homework_6_1.py @@ -0,0 +1,180 @@ +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT + + +# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS + + +from lesson_6.homework_6_1 import swap_first_last, reverse_list, multiply_list_items, smallest_item_list, \ + remove_duplicates_list, longer_words_list, find_item_lists, list_to_string, count_items_list, even_items_list, \ + list_1, list_2, list_3, list_4, list_5, number_1, list_6, list_7, list_8, list_9, number_2, list_10, list_11 +import pytest + + +def test_swap_first_last(): + # You are given a list in list_1 variable, write a swap_first_last function to return a new list with + # the first and the last elements of the list swapped. + if swap_first_last(list_1) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = list_1.copy() + result[0], result[-1] = result[-1], result[0] + assert swap_first_last(list_1) == result + + +def test_reverse_list(): + # You are given a list in list_2 variable, write a reverse_list function which creates a new list in reversed order. + if reverse_list(list_2) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = list_2.copy() + result.reverse() + assert reverse_list(list_1) == result + + +def test_multiply_list_items(): + # Create a list which contains only number items and save it to the list_3 variable. Then write multiply_list_items + # function to multiply all the items in a list. + if list_3 == None or multiply_list_items(list_3) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = 1 + for item in list_3: + result *= item + assert multiply_list_items(list_3) == result + + +def test_smallest_item_list(): + # Create a list which contains only number items and save it to the list_4 variable. Then write a smallest_item_list + # function to get the smallest number from a list + if list_4 == None or smallest_item_list(list_4) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + min_1 = list_4[0] + for item in list_4: + if item < min_1: + min_1 = item + assert smallest_item_list(list_4) == min_1 + + +def test_remove_duplicates_list(): + # Given a list in list_5 variable, write a remove_duplicates_list function to remove duplicates from a list. + if remove_duplicates_list(list_5) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = [] + for item in list_5: + if not item in result: + result.append(item) + assert remove_duplicates_list(list_5) == result + + +def test_longer_words_list(): + # You are given a list in list_6 variable.Enter an integer number and save it to number_1 variable, + # write a longer_words_list function which will return the list of words that are longer than number_1 + # from a given list of words. + if number_1 == None or longer_words_list(list_6, number_1) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = [] + for item in list_6: + if len(item) > number_1: + result.append(item) + assert longer_words_list(list_6, number_1) == result + + +def test_find_item_lists(): + # Given two lists in list_7 and list_8 variables. Write a function find_item_lists that takes two lists and returns + # True if they have at least one common member. + + + if find_item_lists(list_7, list_8) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = False + for item_1 in list_7: + if item_1 in list_8: + result = True + assert find_item_lists(list_7, list_8) == result + + +def test_list_to_string(): + # You are given a list in list_9 variable. Write a function string_to_list to convert a list of + # characters into a string. + + + if list_to_string(list_9) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = ''.join(list_9) + assert list_to_string(list_9) == result + + +def test_count_items_list(): + # Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number + # of occurrences of x in the given list + + + if count_items_list(list_10, number_2) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = list_10.count(number_2) + assert count_items_list(list_10, number_2) == result + + +def test_even_items_list(): + # Given a list of numbers, write a function even_items_list to return new list which include all even numbers in + # given list. + + + if even_items_list(list_11) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = [] + for item in list_11: + if item % 2 == 0: + result.append(item) + assert even_items_list(list_11) == result diff --git a/tests/homework_6_2.py b/tests/homework_6_2.py new file mode 100644 index 0000000..c6beea0 --- /dev/null +++ b/tests/homework_6_2.py @@ -0,0 +1,178 @@ +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT +# PLEASE, DON'T CHEAT + + +# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS + + +from lesson_6.homework_6_2 import countries, your_choice_country, your_choice_number, find_index_by_value, \ + find_value_by_index, new_team_name, new_team_city, nhl_hockey_teams, add_your_own_team, dict_1, dict_2, \ + join_dicts, number_1, create_numbers_dict, dict_3, sum_up_hockey_cups, dict_4, remove_item_by_key, dict_5, \ + find_min_max, dict_6, remove_duplicates + +import pytest + + +def test_find_index_by_value(): + # Enter a country and save it to variable your_choice_country. Write find_index_by_value function which will check + # if the tuple countries contains a country of your choice. If your_choice_country is in the tuple, return its + # index, otherwise return a -1 value + + if your_choice_country == None or find_index_by_value(your_choice_country, countries) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = -1 + if your_choice_country in countries: + result = countries.index(your_choice_country) + assert find_index_by_value(your_choice_country, countries) == result + + +def test_find_value_by_index(): + # Change the previous exercise. Enter a random number and save it to variable your_choice_number. Write + # find_value_by_index function which will check if the tuple countries contains a country with this index. + # If there is a value with this index your_choice_number in the tuple, return this value, + # otherwise return a 'No such index' text + + if your_choice_number == None or find_value_by_index(your_choice_number, countries) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = 'No such index' + if 0 <= your_choice_number < len(countries): + result = countries[your_choice_number] + assert find_value_by_index(your_choice_number, countries) == result + + +def test_add_your_own_team(): + # Enter a pair of values in variables new_team_name, new_team_city. Then write add_your_own_team function + # to add them to nhl_hockey_teams dictionary, where the name will be the key. + + if new_team_name == None or new_team_city == None or add_your_own_team(new_team_name, new_team_city) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + nhl_hockey_teams[new_team_name] = new_team_city + assert add_your_own_team(your_choice_number, countries) == nhl_hockey_teams + + +def test_join_dicts(): + # Create two dictionaries in dict_1, dict_2 variables. Write a join_dicts function to concatenate the following + # dictionaries to create a new one. + + if dict_1 == None or dict_2 == None or join_dicts(dict_1, dict_2) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + assert join_dicts(dict_1, dict_2) == dict_1.join(dict_2) or join_dicts(dict_1, dict_2) == dict_2.join(dict_1) + + +def test_create_numbers_dict(): + # # Enter a random number and save it to number_1 variable. Then write create_numbers_dict function to generate + # a dictionary that contains items with keys from 1 to number_1 and values in format "x": "x**2". + + if number_1 == None or create_numbers_dict(number_1) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = {} + for item in range(1, number_1 + 1): + result[item] = item ** 2 + assert create_numbers_dict(number_1) == result + + +def test_sum_up_hockey_cups(): + # Write sum_up_hockey_cups functions to sum all values in a dictionary dict_3. + + if sum_up_hockey_cups(dict_3) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = 0 + for key in dict_3: + result += dict_3[key] + assert sum_up_hockey_cups(dict_3) == result + + +def test_remove_item_by_key(): + # Write remove_item_by_key function to remove a key True from dict_4 dictionary. + + if remove_item_by_key(dict_4) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + del dict_4[True] + assert remove_item_by_key(dict_4) == dict_4 + + +def test_find_min_max(): + # Write find_min_max function to get the maximum and minimum value in dict_5 dictionary. Return the answer in format + # { + # "min": 111, + # "max": 222 + # } + + if find_min_max(dict_5) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = {} + min_value = None + max_value = None + for item in dict_5: + if dict_5[item] > max_value: + max_value = dict_5[item] + if dict_5[item] < min_value: + min_value = dict_5[item] + result['min'] = min_value + result['max'] = max_value + assert find_min_max(dict_5) == result + + +def test_remove_duplicates(): + # Write remove_duplicates functions to remove duplicates from dictionary dict_6. + + if remove_duplicates(dict_6) == None: + pytest.skip(f"You didn't finish this task. the result variable equals None") + result = {} + for key, value in dict_6.items(): + if value not in dict_6.values(): + result[key] = value + assert remove_duplicates(dict_6) == result From bfca14d3d23b23728b35f4d6b1ef0293d2a46eb4 Mon Sep 17 00:00:00 2001 From: Ilya Tishin Date: Thu, 27 Aug 2020 17:14:59 -0700 Subject: [PATCH 3/5] fix homework 6_1 --- lesson_6/homework_6_1.py | 19 +++++++++++++------ tests/homework_6_1.py | 16 +++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lesson_6/homework_6_1.py b/lesson_6/homework_6_1.py index 77b814a..9e069e3 100644 --- a/lesson_6/homework_6_1.py +++ b/lesson_6/homework_6_1.py @@ -1,5 +1,7 @@ # You are given a list in list_1 variable, write a swap_first_last function to return a new list with # the first and the last elements of the list swapped. +# Return this list + list_1 = [1, 'asdasd', True, 2, False, 4, 'Hello world', None, range(1, 11), 100] def swap_first_last(array_1): @@ -7,6 +9,8 @@ def swap_first_last(array_1): # You are given a list in list_2 variable, write a reverse_list function which creates a new list in reversed order. +# Return this list + list_2 = [1, 'asdasd', True, 2, False, 4, 'Hello world', None, range(1, 11), 100] def reverse_list(array_2): @@ -14,7 +18,8 @@ def reverse_list(array_2): # Create a list which contains only number items and save it to the list_3 variable. Then write multiply_list_items -# function to multiply all the items in a list. +# function to multiply all the items in a list. Return result of multiplication + list_3 = None def multiply_list_items(array_3): @@ -22,7 +27,8 @@ def multiply_list_items(array_3): # Create a list which contains only number items and save it to the list_4 variable. Then write a smallest_item_list -# function to get the smallest number from a list +# function to get the smallest number from a list. Return smallest element + list_4 = [10, 2, 5, 5, 0] def smallest_item_list(array_4): @@ -30,6 +36,8 @@ def smallest_item_list(array_4): # Given a list in list_5 variable, write a remove_duplicates_list function to remove duplicates from a list. +# Return new list without duplicates + list_5 = [1, 2, 3, 1, 1, 1, 2, 3, 4, 'hello', 1, 2, 3, 4, 'hello', 'hello', 1] def remove_duplicates_list(array_5): @@ -39,7 +47,7 @@ def remove_duplicates_list(array_5): # You are given a list in list_6 variable.Enter an integer number and save it to number_1 variable, # write a longer_words_list function which will return the list of words that are longer than number_1 # from a given list of words. -number_1 = 5 +number_1 = None list_6 = ['On', 'it', 'differed', 'repeated', 'wandered', 'required', 'in.', 'Then', 'girl', 'neat', 'why', 'yet', 'knew', 'rose', 'spot.', 'Moreover', 'property', 'we', 'he', 'kindness', 'greatest', 'be', 'oh', 'striking', 'laughter.', 'In', 'me', 'he', 'at', 'collecting', 'affronting', 'principles', 'apartments.', 'Has', 'visitor', @@ -60,8 +68,7 @@ def longer_words_list(array_6, number1): def find_item_lists(array_7, array_8): pass - -# You are given a list in list_9 variable. Write a function string_to_list to convert a list of +# You are given a list in list_9 variable. Write a function list_to_string to convert a list of # characters into a string. list_9 = ['I', ' ', 'l', 'i', 'k', 'e', ' ', 'P', 'y', 't', 'h', 'o', 'n'] @@ -70,7 +77,7 @@ def list_to_string(list9): # Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number of -# occurrences of x in the given list +# occurrences of number_2 in the given list list_10 = [1, 2, 3, 1, 1, 1, 2, 3, 4] number_2 = 3 diff --git a/tests/homework_6_1.py b/tests/homework_6_1.py index 5c5500e..a57dfb2 100644 --- a/tests/homework_6_1.py +++ b/tests/homework_6_1.py @@ -67,6 +67,8 @@ def test_swap_first_last(): # You are given a list in list_1 variable, write a swap_first_last function to return a new list with # the first and the last elements of the list swapped. + # Return this list + if swap_first_last(list_1) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") result = list_1.copy() @@ -76,6 +78,7 @@ def test_swap_first_last(): def test_reverse_list(): # You are given a list in list_2 variable, write a reverse_list function which creates a new list in reversed order. + # Return this list if reverse_list(list_2) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") result = list_2.copy() @@ -85,7 +88,7 @@ def test_reverse_list(): def test_multiply_list_items(): # Create a list which contains only number items and save it to the list_3 variable. Then write multiply_list_items - # function to multiply all the items in a list. + # function to multiply all the items in a list. Return result of multiplication if list_3 == None or multiply_list_items(list_3) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") result = 1 @@ -96,7 +99,7 @@ def test_multiply_list_items(): def test_smallest_item_list(): # Create a list which contains only number items and save it to the list_4 variable. Then write a smallest_item_list - # function to get the smallest number from a list + # function to get the smallest number from a list. Return smallest element if list_4 == None or smallest_item_list(list_4) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") min_1 = list_4[0] @@ -108,6 +111,7 @@ def test_smallest_item_list(): def test_remove_duplicates_list(): # Given a list in list_5 variable, write a remove_duplicates_list function to remove duplicates from a list. + # Return new list without duplicates if remove_duplicates_list(list_5) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") result = [] @@ -145,10 +149,9 @@ def test_find_item_lists(): def test_list_to_string(): - # You are given a list in list_9 variable. Write a function string_to_list to convert a list of + # You are given a list in list_9 variable. Write a function list_to_string to convert a list of # characters into a string. - if list_to_string(list_9) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") result = ''.join(list_9) @@ -156,9 +159,8 @@ def test_list_to_string(): def test_count_items_list(): - # Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number - # of occurrences of x in the given list - + # Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number of + # occurrences of number_2 in the given list if count_items_list(list_10, number_2) == None: pytest.skip(f"You didn't finish this task. the result variable equals None") From dad75b48969fee0641848146bec2e6fd03358ea7 Mon Sep 17 00:00:00 2001 From: Ilya Tishin Date: Thu, 27 Aug 2020 18:14:49 -0700 Subject: [PATCH 4/5] remove homework 6_2 --- lesson_6/homework_6_2.py | 163 ----------------------------------- tests/homework_6_2.py | 178 --------------------------------------- 2 files changed, 341 deletions(-) delete mode 100644 lesson_6/homework_6_2.py delete mode 100644 tests/homework_6_2.py diff --git a/lesson_6/homework_6_2.py b/lesson_6/homework_6_2.py deleted file mode 100644 index 6d301ac..0000000 --- a/lesson_6/homework_6_2.py +++ /dev/null @@ -1,163 +0,0 @@ -# Enter a country and save it to variable your_choice_country. Write find_index_by_value function which will check -# if the tuple countries contains a country of your choice. If your_choice_country is in the tuple, return its -# index, otherwise return a -1 value - -countries = ('USA', 'Canada', 'United Kingdom', 'Mexico', 'Brazil', 'Argentina', 'Chili', 'South Africa', 'Egypt', - 'Morocco', 'India', 'China', 'Ukraine', 'Spain', 'France', 'Russia') -your_choice_country = None - -def find_index_by_value(value, tuple1): - pass - - -# Change the previous exercise. Enter a random number and save it to variable your_choice_number. Write -# find_value_by_index function which will check if the tuple countries contains a country with this index. -# If there is a value with this index your_choice_number in the tuple, return this value, -# otherwise return a 'No such index' text - -your_choice_number = None - -def find_value_by_index(index, tuple1): - pass - - -# Enter a pair of values in variables new_team_name, new_team_city. Then write add_your_own_team function -# to add them to nhl_hockey_teams dictionary, where the name will be the key. - -new_team_name = None -new_team_city = None - -nhl_hockey_teams = { - "Canadiens": "Montreal", - "Maple Leafs": "Toronto", - "Red Wings": "Detroit", - "Bruins": "Boston", - "Blackhawks": "Chicago", - "Oilers": "Edmonton", - "Penguins": "Pittsburgh", - "Islanders": "New York", - "Rangers": "New York", - "Devils": "New Jersey", - "Avalanche": "Colorado", - "Kings": "Los Angeles", - "Flyers": "Philadelphia", - "Ducks": "Anaheim", - "Flames": "Calgary", - "Hurricanes": "Carolina", - "Stars": "Dallas", - "Blues": "St. Louis", - "Lightning": "Tampa Bay", - "Capitals": "Washington" -} - -def add_your_own_team(team_name, team_city): - pass - - -# Create two dictionaries in dict_1, dict_2 variables. Write a join_dicts function to concatenate the following -# dictionaries to create a new one. - -dict_1 = None -dict_2 = None - -def join_dicts(dict1, dict2): - pass - - -# # Enter a random number and save it to number_1 variable. Then write create_numbers_dict function to generate -# a dictionary that contains items with keys from 1 to number_1 and values in format "x": "x**2". - -number_1 = None - -def create_numbers_dict(number1): - pass - - -# Write sum_up_hockey_cups functions to sum all values in a dictionary dict_3. - -dict_3 = { - "Montreal Canadiens": 24, - "Toronto Maple Leafs": 13, - "Detroit Red Wings": 11, - "Boston Bruins": 6, - "Chicago Blackhawks": 6, - "Edmonton Oilers": 5, - "Pittsburgh Penguins": 5, - "New York Islanders": 4, - "New York Rangers": 4, - "New Jersey Devils": 3, - "Colorado Avalanche": 2, - "Los Angeles Kings": 2, - "Philadelphia Flyers": 2, - "Anaheim Ducks": 1, - "Calgary Flames": 1, - "Carolina Hurricanes": 1, - "Dallas Stars": 1, - "St. Louis Blues": 1, - "Tampa Bay Lightning": 1, - "Washington Capitals": 1 -} - -def sum_up_hockey_cups(teams_dict): - pass - - -# Write remove_item_by_key function to remove a key True from dict_4 dictionary. - -dict_4 = { - "a": 231, - "b": 'hello', - True: False, - 42: 'answer' -} - -def remove_item_by_key(dict1): - pass - - -# Write find_min_max function to get the maximum and minimum value in dict_5 dictionary. Return the answer in format -# { -# "min": 111, -# "max": 222 -# } - -dict_5 = { - "Cyprus": 1207359, - "Czechia": 10708981, - "Democratic Republic of the Congo": 89561403, - "Denmark": 5792202, - "Djibouti": 988000, - "Dominica": 71986, - "Dominican Republic": 10847910, - "Ecuador": 17643054, - "Egypt": 102334404, - "El Salvador": 6486205, - "Equatorial Guinea": 1402985, - "Eritrea": 3546421, - "Estonia": 1326535, - "Eswatini": 1160164, - "Ethiopia": 114963588, - "Fiji": 896445, -} - -def find_min_max(dict1): - pass - - -# Write remove_duplicates functions to remove duplicates from dictionary dict_6. - -dict_6 = { - "Lessie": "collie", - "Marlie": "labrador", - "Spike": "boxer", - "Buddy": "labrador", - "Milo": "labrador", - "Archie": "corgi", - "Tobby": "pit bull", - "Jack": "poodle", - "Lucy": "german shepherd", - "Bailey": "labrador" -} - -def remove_duplicates(dict1): - pass diff --git a/tests/homework_6_2.py b/tests/homework_6_2.py deleted file mode 100644 index c6beea0..0000000 --- a/tests/homework_6_2.py +++ /dev/null @@ -1,178 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_6.homework_6_2 import countries, your_choice_country, your_choice_number, find_index_by_value, \ - find_value_by_index, new_team_name, new_team_city, nhl_hockey_teams, add_your_own_team, dict_1, dict_2, \ - join_dicts, number_1, create_numbers_dict, dict_3, sum_up_hockey_cups, dict_4, remove_item_by_key, dict_5, \ - find_min_max, dict_6, remove_duplicates - -import pytest - - -def test_find_index_by_value(): - # Enter a country and save it to variable your_choice_country. Write find_index_by_value function which will check - # if the tuple countries contains a country of your choice. If your_choice_country is in the tuple, return its - # index, otherwise return a -1 value - - if your_choice_country == None or find_index_by_value(your_choice_country, countries) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = -1 - if your_choice_country in countries: - result = countries.index(your_choice_country) - assert find_index_by_value(your_choice_country, countries) == result - - -def test_find_value_by_index(): - # Change the previous exercise. Enter a random number and save it to variable your_choice_number. Write - # find_value_by_index function which will check if the tuple countries contains a country with this index. - # If there is a value with this index your_choice_number in the tuple, return this value, - # otherwise return a 'No such index' text - - if your_choice_number == None or find_value_by_index(your_choice_number, countries) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = 'No such index' - if 0 <= your_choice_number < len(countries): - result = countries[your_choice_number] - assert find_value_by_index(your_choice_number, countries) == result - - -def test_add_your_own_team(): - # Enter a pair of values in variables new_team_name, new_team_city. Then write add_your_own_team function - # to add them to nhl_hockey_teams dictionary, where the name will be the key. - - if new_team_name == None or new_team_city == None or add_your_own_team(new_team_name, new_team_city) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - nhl_hockey_teams[new_team_name] = new_team_city - assert add_your_own_team(your_choice_number, countries) == nhl_hockey_teams - - -def test_join_dicts(): - # Create two dictionaries in dict_1, dict_2 variables. Write a join_dicts function to concatenate the following - # dictionaries to create a new one. - - if dict_1 == None or dict_2 == None or join_dicts(dict_1, dict_2) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert join_dicts(dict_1, dict_2) == dict_1.join(dict_2) or join_dicts(dict_1, dict_2) == dict_2.join(dict_1) - - -def test_create_numbers_dict(): - # # Enter a random number and save it to number_1 variable. Then write create_numbers_dict function to generate - # a dictionary that contains items with keys from 1 to number_1 and values in format "x": "x**2". - - if number_1 == None or create_numbers_dict(number_1) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = {} - for item in range(1, number_1 + 1): - result[item] = item ** 2 - assert create_numbers_dict(number_1) == result - - -def test_sum_up_hockey_cups(): - # Write sum_up_hockey_cups functions to sum all values in a dictionary dict_3. - - if sum_up_hockey_cups(dict_3) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = 0 - for key in dict_3: - result += dict_3[key] - assert sum_up_hockey_cups(dict_3) == result - - -def test_remove_item_by_key(): - # Write remove_item_by_key function to remove a key True from dict_4 dictionary. - - if remove_item_by_key(dict_4) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - del dict_4[True] - assert remove_item_by_key(dict_4) == dict_4 - - -def test_find_min_max(): - # Write find_min_max function to get the maximum and minimum value in dict_5 dictionary. Return the answer in format - # { - # "min": 111, - # "max": 222 - # } - - if find_min_max(dict_5) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = {} - min_value = None - max_value = None - for item in dict_5: - if dict_5[item] > max_value: - max_value = dict_5[item] - if dict_5[item] < min_value: - min_value = dict_5[item] - result['min'] = min_value - result['max'] = max_value - assert find_min_max(dict_5) == result - - -def test_remove_duplicates(): - # Write remove_duplicates functions to remove duplicates from dictionary dict_6. - - if remove_duplicates(dict_6) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = {} - for key, value in dict_6.items(): - if value not in dict_6.values(): - result[key] = value - assert remove_duplicates(dict_6) == result From 79fcc7d2708056b446096de98d20796a81b1b7bb Mon Sep 17 00:00:00 2001 From: "nenaviju4tverg@gmail.com" Date: Thu, 3 Dec 2020 17:00:33 -0800 Subject: [PATCH 5/5] rollback to default --- README.md | 9 +- lesson_1/homework_1_4.py | 28 ----- lesson_1/homework_1_5.py | 23 ---- lesson_1/homework_1_6.py | 7 -- lesson_2/homework_2_1.py | 49 +++------ lesson_2/homework_2_2.py | 45 +++----- lesson_2/homework_2_3.py | 55 ++-------- lesson_3/homework_3_1.py | 55 +++++----- lesson_3/homework_3_2.py | 45 +++++--- {tests => lesson_4}/__init__.py | 0 lesson_4/homework_4_1.py | 50 +++++++++ lesson_4/homework_4_2.py | 38 +++++++ lesson_4/homework_4_3.py | 23 ++++ lesson_7/__init__.py | 0 lesson_7/homework_7_1.py | 157 +++++++++++++++++++++++++++ requirements.txt | 2 - tests/homework_1_1.py | 126 ---------------------- tests/homework_1_2.py | 98 ----------------- tests/homework_1_3.py | 93 ---------------- tests/homework_1_4.py | 108 ------------------- tests/homework_1_5.py | 93 ---------------- tests/homework_1_6.py | 74 ------------- tests/homework_2_1.py | 158 --------------------------- tests/homework_2_2.py | 131 ----------------------- tests/homework_2_3.py | 122 --------------------- tests/homework_3_1.py | 104 ------------------ tests/homework_3_2.py | 101 ------------------ tests/homework_5_1.py | 105 ------------------ tests/homework_6_1.py | 182 -------------------------------- 29 files changed, 367 insertions(+), 1714 deletions(-) delete mode 100644 lesson_1/homework_1_4.py delete mode 100644 lesson_1/homework_1_5.py delete mode 100644 lesson_1/homework_1_6.py rename {tests => lesson_4}/__init__.py (100%) create mode 100644 lesson_4/homework_4_1.py create mode 100644 lesson_4/homework_4_2.py create mode 100644 lesson_4/homework_4_3.py create mode 100644 lesson_7/__init__.py create mode 100644 lesson_7/homework_7_1.py delete mode 100644 requirements.txt delete mode 100644 tests/homework_1_1.py delete mode 100644 tests/homework_1_2.py delete mode 100644 tests/homework_1_3.py delete mode 100644 tests/homework_1_4.py delete mode 100644 tests/homework_1_5.py delete mode 100644 tests/homework_1_6.py delete mode 100644 tests/homework_2_1.py delete mode 100644 tests/homework_2_2.py delete mode 100644 tests/homework_2_3.py delete mode 100644 tests/homework_3_1.py delete mode 100644 tests/homework_3_2.py delete mode 100644 tests/homework_5_1.py delete mode 100644 tests/homework_6_1.py diff --git a/README.md b/README.md index de84cd9..c6cf2be 100644 --- a/README.md +++ b/README.md @@ -1,8 +1 @@ -# JobEasy Python course - -To check your homework: - -1. Install Python packages listed in requirements.txt file -2. Move in terminal to folder 'tests' (enter `cd tests`) -3. Run `pytest homework_1_1.py -r chars --cache-clear` in terminal, where homework_1_1.py is the name of your homework, -which you'd like to check +# JobEasy Python course homework diff --git a/lesson_1/homework_1_4.py b/lesson_1/homework_1_4.py deleted file mode 100644 index e82da2d..0000000 --- a/lesson_1/homework_1_4.py +++ /dev/null @@ -1,28 +0,0 @@ -# Create three strings using three different methods. Save your result to result_string_1, result_string_2, -# result_string_3 variables - -result_string_1 = None -result_string_2 = None -result_string_3 = None - - -# Enter your first and last name. Join them together with a space in -# between. Save a result in a variable result_full_name and -# save the length of the whole name in result_full_name_length variable. - -first_name = None -last_name = None -result_full_name = None -result_full_name_length = None - - -# Enter the capital city of California State in lower case. Change the case to title case. -# Save the result in result_ca_capital variable - -result_ca_capital = None - - -# Enter the name of our planet. Change the case to upper case. Save the result in -# result_planet variable - -result_planet = None diff --git a/lesson_1/homework_1_5.py b/lesson_1/homework_1_5.py deleted file mode 100644 index fd193ff..0000000 --- a/lesson_1/homework_1_5.py +++ /dev/null @@ -1,23 +0,0 @@ -# Change result_string_1 that 'very simple language' will be displayed on a new line - -result_string_1 = 'Python is the very simple language' - - -# Change result_string_2 to print out the phrase: 'What does the word 'integer' mean' - -result_string_2 = 'What does the word 'integer' mean' - - -# Assign number variable to value "5" (as a string). Then rise the number to the power 3. -# Save the expression to result_value variable - -number = None -result_value = None - - -# Enter a random number, then save the value to n variable. -# Finally, you should repeat the variable "word" n times and save the value to result_string_3 - -n = None -word = 'super' -result_string_3 = None diff --git a/lesson_1/homework_1_6.py b/lesson_1/homework_1_6.py deleted file mode 100644 index 10e6acc..0000000 --- a/lesson_1/homework_1_6.py +++ /dev/null @@ -1,7 +0,0 @@ -# Write your first program. Enter the temperature right now in Fahrenheit in temperature_fahrenheit variable as -# a string (e.g. '75') and convert it to Celsius. -# !important you should save only number to result_temperature. Formula (32°F − 32) × 5/9 = 0°C - -# type your code here -temperature_fahrenheit = None -result_temperature = None diff --git a/lesson_2/homework_2_1.py b/lesson_2/homework_2_1.py index cae2054..e82da2d 100644 --- a/lesson_2/homework_2_1.py +++ b/lesson_2/homework_2_1.py @@ -1,45 +1,28 @@ -# Enter two numbers. If the first one is greater than the second, save first number in result_1, -# otherwise save the second number to the result_1 variable. +# Create three strings using three different methods. Save your result to result_string_1, result_string_2, +# result_string_3 variables -first_number = None -second_number = None -result_1 = None +result_string_1 = None +result_string_2 = None +result_string_3 = None -# Enter a random number in number_1 variable. If this number is 20 or -# higher save “Too high” text to result_2, otherwise save “Thank you”. -number_1 = None -result_2 = None - -# Enter your first name and last name in first_name and last_name variables. If the length of your first name is under -# five characters, join them together (without a space) and save it to result_3 variable in upper case. If the length -# of the first name is five or more characters, save their first name in lower case in result_3 variable. +# Enter your first and last name. Join them together with a space in +# between. Save a result in a variable result_full_name and +# save the length of the whole name in result_full_name_length variable. first_name = None last_name = None -result_3 = None - - -# Enter a number between 10 and 20 (inclusive) and save number to number_2 variable -# If they enter a number within this range, save a message “Thank you” to result_4, otherwise a -# message “Incorrect answer” to result_4. - -number_2 = None -result_4 = None +result_full_name = None +result_full_name_length = None -# Enter your age. If you are 18 or over, save the message “You can vote” in result_5, -# if you are aged 17, save the message “You can learn to drive” in result_5 variable, -# if you are 16, save the message “You can buy a lottery ticket” in result_5, -# if you are under 16, save the message “You can go Trick-or-Treating” in result_5 variable. +# Enter the capital city of California State in lower case. Change the case to title case. +# Save the result in result_ca_capital variable -age = None -result_5 = None +result_ca_capital = None -# Enter a number between 1 and 12, save this value to month variable. Find which month is it. -# (January, February, March, April, May, June, Jule, August, September, October, November, December) -# Write answer in result_month in lower case +# Enter the name of our planet. Change the case to upper case. Save the result in +# result_planet variable -month = None -result_month = None \ No newline at end of file +result_planet = None diff --git a/lesson_2/homework_2_2.py b/lesson_2/homework_2_2.py index a7c8902..fd193ff 100644 --- a/lesson_2/homework_2_2.py +++ b/lesson_2/homework_2_2.py @@ -1,40 +1,23 @@ -# Enter a number between 1 and 20, save this value to number variable. -# If number is greater than 0 and less than or equal to 7, save the number * 10 to result_1. -# If number is greater than 7 and less than or equal to 15, save the result of floor division of the number divided by -# 3 to result_1 variable -# If number is greater than 15 and less than or equal to 20, save the number raised to the power 3 to result_1 -# Else save the text "Wrong value" to result_1 +# Change result_string_1 that 'very simple language' will be displayed on a new line + +result_string_1 = 'Python is the very simple language' -number = None -result_1 = None +# Change result_string_2 to print out the phrase: 'What does the word 'integer' mean' -# Enter two numbers between 1 and 10, save this values to number_1 variable and number_2 variables. -# If number_1 and number_2 are greater than 0 and less than or equal to 5 save in the product of their multiplication -# to result_2 -# If one of the variables (number_1 or number_2) is greater than 5 and less than or equal to 10, but the other isn't, -# then save the sum of the two numbers to result_2 -# If both numbers are greater than 5 and less than or equal to 10, multiply their sum by 3 and save it to result_2 -# Else save the text "Wrong values, try again" to result_2 +result_string_2 = 'What does the word 'integer' mean' -number_1 = None -number_2 = None -result_2 = None -# Enter your first name and save it to first_name variable, -# then Enter last name and save it to last_name -# If first_name or last_name are shorter than 6 characters, save a full name (with a space between) to result_3 -# Else save first_name to result_3 as many times as length of last_name value +# Assign number variable to value "5" (as a string). Then rise the number to the power 3. +# Save the expression to result_value variable -first_name = None -last_name = None -result_3 = None +number = None +result_value = None -# Enter a random number. Save this value to random_number variable -# If this number is less 10 or greater than 99, save the text "Please, put in a number between 10 and 99" to result_4 -# If a number doesn't meet the first condition, find the remainder of random_value divided by 2. -# If it is 0, save the text "Even number" to result_4 , else save the message "Odd number" +# Enter a random number, then save the value to n variable. +# Finally, you should repeat the variable "word" n times and save the value to result_string_3 -random_number = None -result_4 = None +n = None +word = 'super' +result_string_3 = None diff --git a/lesson_2/homework_2_3.py b/lesson_2/homework_2_3.py index 42f5d6a..10e6acc 100644 --- a/lesson_2/homework_2_3.py +++ b/lesson_2/homework_2_3.py @@ -1,50 +1,7 @@ -# Save to variable result_1 the first character of string_1 variable. In result_2 save the last character -# of string_1. Use indexes. +# Write your first program. Enter the temperature right now in Fahrenheit in temperature_fahrenheit variable as +# a string (e.g. '75') and convert it to Celsius. +# !important you should save only number to result_temperature. Formula (32°F − 32) × 5/9 = 0°C -string_1 = 'Python' -result_1 = None -result_2 = None - - -# Save to variable result_3 string value from string_2 variable, written in reverse order, using concatenation. - -string_2 = 'Python' -result_3 = None - - -# Slice string string_3 from 5th to 20th (excluding 20th) character and save the result to variable result_4 - -string_3 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' -result_4 = None - - -# Slice string string_4 from 10th character to the end of the string. Save only every second character to variable -# result_5 - -string_4 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' -result_5 = None - - -# Slice string string_5 from the first to the last character, save only every forth character and -# save the result to variable result_6 - -string_5 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' -result_6 = None - - -# Slice string string_6 from the first to 14th (including 14th) character, save only every third character and save -# the result to variable result_7 - -string_6 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' -result_7 = None - - -# Save to variable result_8 string value from string_7 variable, written in reverse order, using slicing. - -string_7 = 'Python' -result_8 = None - - -# Create a range of numbers from 0 to 10 (excluding 10) and save it to result_9 variable - -result_9 = None +# type your code here +temperature_fahrenheit = None +result_temperature = None diff --git a/lesson_3/homework_3_1.py b/lesson_3/homework_3_1.py index f8b33ff..cae2054 100644 --- a/lesson_3/homework_3_1.py +++ b/lesson_3/homework_3_1.py @@ -1,38 +1,45 @@ -# FOR LOOPS EXERCISES +# Enter two numbers. If the first one is greater than the second, save first number in result_1, +# otherwise save the second number to the result_1 variable. -# Ex. 1 -# Enter your name, save it in name variable and save in result_1 variable your name repeated 3 times (use loops) - -name_1 = None +first_number = None +second_number = None result_1 = None -# TODO: Here is your code - - -# Ex. 2 -# Modify your previous program so that it will enter your name (save it in variable name_2) and a number -# (save in variable number) and then save in result_2 variable your name repeated as many times as number_1 is -# (use loops) -name_2 = None +# Enter a random number in number_1 variable. If this number is 20 or +# higher save “Too high” text to result_2, otherwise save “Thank you”. number_1 = None result_2 = None -# TODO: Here is your code +# Enter your first name and last name in first_name and last_name variables. If the length of your first name is under +# five characters, join them together (without a space) and save it to result_3 variable in upper case. If the length +# of the first name is five or more characters, save their first name in lower case in result_3 variable. -# Ex. 3 -# Enter a random string, which includes only digits. Write code which find a sum of digits in this string and save it -# into result_3 variable - -string_number_1 = None +first_name = None +last_name = None result_3 = None -# TODO: Here is your code - -# Ex. 4 -# Create code which sums up all even numbers between 2 and 100 (include 100) and save it in result_4 variable +# Enter a number between 10 and 20 (inclusive) and save number to number_2 variable +# If they enter a number within this range, save a message “Thank you” to result_4, otherwise a +# message “Incorrect answer” to result_4. +number_2 = None result_4 = None -# TODO: Here is your code \ No newline at end of file + +# Enter your age. If you are 18 or over, save the message “You can vote” in result_5, +# if you are aged 17, save the message “You can learn to drive” in result_5 variable, +# if you are 16, save the message “You can buy a lottery ticket” in result_5, +# if you are under 16, save the message “You can go Trick-or-Treating” in result_5 variable. + +age = None +result_5 = None + + +# Enter a number between 1 and 12, save this value to month variable. Find which month is it. +# (January, February, March, April, May, June, Jule, August, September, October, November, December) +# Write answer in result_month in lower case + +month = None +result_month = None \ No newline at end of file diff --git a/lesson_3/homework_3_2.py b/lesson_3/homework_3_2.py index 1c51ea0..a7c8902 100644 --- a/lesson_3/homework_3_2.py +++ b/lesson_3/homework_3_2.py @@ -1,23 +1,40 @@ -# WHILE LOOPS EXERCISES - -# Enter a random string in the variable string_1, then enter a character and save it in the variable char_1. -# Write code, which will count how many times your character is included in your string. -# Save result to result_1 variable - -string_1 = None -char_1 = None +# Enter a number between 1 and 20, save this value to number variable. +# If number is greater than 0 and less than or equal to 7, save the number * 10 to result_1. +# If number is greater than 7 and less than or equal to 15, save the result of floor division of the number divided by +# 3 to result_1 variable +# If number is greater than 15 and less than or equal to 20, save the number raised to the power 3 to result_1 +# Else save the text "Wrong value" to result_1 + +number = None result_1 = None -# Enter a random number and save it in variable number_1. Then create code to multiply all the digits together -# and save result in the result_2 variable. +# Enter two numbers between 1 and 10, save this values to number_1 variable and number_2 variables. +# If number_1 and number_2 are greater than 0 and less than or equal to 5 save in the product of their multiplication +# to result_2 +# If one of the variables (number_1 or number_2) is greater than 5 and less than or equal to 10, but the other isn't, +# then save the sum of the two numbers to result_2 +# If both numbers are greater than 5 and less than or equal to 10, multiply their sum by 3 and save it to result_2 +# Else save the text "Wrong values, try again" to result_2 number_1 = None +number_2 = None result_2 = None +# Enter your first name and save it to first_name variable, +# then Enter last name and save it to last_name +# If first_name or last_name are shorter than 6 characters, save a full name (with a space between) to result_3 +# Else save first_name to result_3 as many times as length of last_name value -# Enter a random number and save it in variable number_2. Then create code which will return -# a number with digits of number_1 in reverse order. Save it in result_3 variable +first_name = None +last_name = None +result_3 = None -number_2 = None -result_3 = None \ No newline at end of file + +# Enter a random number. Save this value to random_number variable +# If this number is less 10 or greater than 99, save the text "Please, put in a number between 10 and 99" to result_4 +# If a number doesn't meet the first condition, find the remainder of random_value divided by 2. +# If it is 0, save the text "Even number" to result_4 , else save the message "Odd number" + +random_number = None +result_4 = None diff --git a/tests/__init__.py b/lesson_4/__init__.py similarity index 100% rename from tests/__init__.py rename to lesson_4/__init__.py diff --git a/lesson_4/homework_4_1.py b/lesson_4/homework_4_1.py new file mode 100644 index 0000000..42f5d6a --- /dev/null +++ b/lesson_4/homework_4_1.py @@ -0,0 +1,50 @@ +# Save to variable result_1 the first character of string_1 variable. In result_2 save the last character +# of string_1. Use indexes. + +string_1 = 'Python' +result_1 = None +result_2 = None + + +# Save to variable result_3 string value from string_2 variable, written in reverse order, using concatenation. + +string_2 = 'Python' +result_3 = None + + +# Slice string string_3 from 5th to 20th (excluding 20th) character and save the result to variable result_4 + +string_3 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' +result_4 = None + + +# Slice string string_4 from 10th character to the end of the string. Save only every second character to variable +# result_5 + +string_4 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' +result_5 = None + + +# Slice string string_5 from the first to the last character, save only every forth character and +# save the result to variable result_6 + +string_5 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' +result_6 = None + + +# Slice string string_6 from the first to 14th (including 14th) character, save only every third character and save +# the result to variable result_7 + +string_6 = 'Python is a programming language that lets you work quickly and integrate systems more effectively' +result_7 = None + + +# Save to variable result_8 string value from string_7 variable, written in reverse order, using slicing. + +string_7 = 'Python' +result_8 = None + + +# Create a range of numbers from 0 to 10 (excluding 10) and save it to result_9 variable + +result_9 = None diff --git a/lesson_4/homework_4_2.py b/lesson_4/homework_4_2.py new file mode 100644 index 0000000..f8b33ff --- /dev/null +++ b/lesson_4/homework_4_2.py @@ -0,0 +1,38 @@ +# FOR LOOPS EXERCISES + +# Ex. 1 +# Enter your name, save it in name variable and save in result_1 variable your name repeated 3 times (use loops) + +name_1 = None +result_1 = None + +# TODO: Here is your code + + +# Ex. 2 +# Modify your previous program so that it will enter your name (save it in variable name_2) and a number +# (save in variable number) and then save in result_2 variable your name repeated as many times as number_1 is +# (use loops) +name_2 = None +number_1 = None +result_2 = None + +# TODO: Here is your code + + +# Ex. 3 +# Enter a random string, which includes only digits. Write code which find a sum of digits in this string and save it +# into result_3 variable + +string_number_1 = None +result_3 = None + +# TODO: Here is your code + + +# Ex. 4 +# Create code which sums up all even numbers between 2 and 100 (include 100) and save it in result_4 variable + +result_4 = None + +# TODO: Here is your code \ No newline at end of file diff --git a/lesson_4/homework_4_3.py b/lesson_4/homework_4_3.py new file mode 100644 index 0000000..1c51ea0 --- /dev/null +++ b/lesson_4/homework_4_3.py @@ -0,0 +1,23 @@ +# WHILE LOOPS EXERCISES + +# Enter a random string in the variable string_1, then enter a character and save it in the variable char_1. +# Write code, which will count how many times your character is included in your string. +# Save result to result_1 variable + +string_1 = None +char_1 = None +result_1 = None + + +# Enter a random number and save it in variable number_1. Then create code to multiply all the digits together +# and save result in the result_2 variable. + +number_1 = None +result_2 = None + + +# Enter a random number and save it in variable number_2. Then create code which will return +# a number with digits of number_1 in reverse order. Save it in result_3 variable + +number_2 = None +result_3 = None \ No newline at end of file diff --git a/lesson_7/__init__.py b/lesson_7/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lesson_7/homework_7_1.py b/lesson_7/homework_7_1.py new file mode 100644 index 0000000..679377b --- /dev/null +++ b/lesson_7/homework_7_1.py @@ -0,0 +1,157 @@ +# Enter a country and save it to variable your_choice_country. Write find_index_by_value function which will check +# if the tuple countries contains a country of your choice. If your_choice_country is in the tuple, return its +# index, otherwise return a -1 value + +countries = ('USA', 'Canada', 'United Kingdom', 'Mexico', 'Brazil', 'Argentina', 'Chili', 'South Africa', 'Egypt', + 'Morocco', 'India', 'China', 'Ukraine', 'Spain', 'France', 'Russia') +your_choice_country = 'Canada' + +def find_index_by_value(value, tuple1): + pass + + +# Change the previous exercise. Enter a random number and save it to variable your_choice_number. Write +# find_value_by_index function which will check if the tuple countries contains a country with this index. +# If there is a value with this index your_choice_number in the tuple, return this value, +# otherwise return a 'No such index' text + +your_choice_number = 7 + +def find_value_by_index(index, tuple1): + pass + + +# Enter a pair of values in variables new_team_name, new_team_city. Then write add_your_own_team function +# to add them to nhl_hockey_teams dictionary, where the name will be the key. + +new_team_name = "Wild Russians" +new_team_city = "Moscow" + +nhl_hockey_teams = { + "Canadiens": "Montreal", + "Maple Leafs": "Toronto", + "Red Wings": "Detroit", + "Bruins": "Boston", + "Blackhawks": "Chicago", + "Oilers": "Edmonton", + "Penguins": "Pittsburgh", + "Islanders": "New York", + "Rangers": "New York", + "Devils": "New Jersey", + "Avalanche": "Colorado", + "Kings": "Los Angeles", + "Flyers": "Philadelphia", + "Ducks": "Anaheim", + "Flames": "Calgary", + "Hurricanes": "Carolina", + "Stars": "Dallas", + "Blues": "St. Louis", + "Lightning": "Tampa Bay", + "Capitals": "Washington" +} + +def add_your_own_team(team_name, team_city): + pass + + +# Create two dictionaries in dict_1, dict_2 variables. Write a join_dicts function to concatenate the following +# dictionaries to create a new one. + +dict_1 = None +dict_2 = None + +def join_dicts(dict1, dict2): + pass + + +# # Enter a random number and save it to number_1 variable. Then write create_numbers_dict function to generate +# a dictionary that contains items with keys from 1 to number_1 and values in format "x": "x**2". + +number_1 = None + +def create_numbers_dict(number1): + pass + + +# Write sum_up_hockey_cups functions to sum all values in a dictionary dict_3. + +dict_3 = { + "Montreal Canadiens": 24, + "Toronto Maple Leafs": 13, + "Detroit Red Wings": 11, + "Boston Bruins": 6, + "Chicago Blackhawks": 6, + "Edmonton Oilers": 5, + "Pittsburgh Penguins": 5, + "New York Islanders": 4, + "New York Rangers": 4, + "New Jersey Devils": 3, + "Colorado Avalanche": 2, + "Los Angeles Kings": 2, + "Philadelphia Flyers": 2, + "Anaheim Ducks": 1, + "Calgary Flames": 1, + "Carolina Hurricanes": 1, + "Dallas Stars": 1, + "St. Louis Blues": 1, + "Tampa Bay Lightning": 1, + "Washington Capitals": 1 +} + +def sum_up_hockey_cups(teams_dict, result = 0): + pass + + +# Write remove_item_by_key function to remove a key True from dict_4 dictionary. + +dict_4 = { + "a": 231, + "b": 'hello', + True: False, + 42: 'answer' +} + +def remove_item_by_key(dict1): + pass + + +dict_5 = { + "Cyprus": 1207359, + "Czechia": 10708981, + "Democratic Republic of the Congo": 89561403, + "Denmark": 5792202, + "Djibouti": 988000, + "Dominica": 71986, + "Dominican Republic": 10847910, + "Ecuador": 17643054, + "Egypt": 102334404, + "El Salvador": 6486205, + "Equatorial Guinea": 1402985, + "Eritrea": 3546421, + "Estonia": 1326535, + "Eswatini": 1160164, + "Ethiopia": 114963588, + "Fiji": 896445, +} + +def find_min_max(dict1): + pass + + +# Write remove_duplicates functions to remove duplicates from dictionary dict_6. + +dict_6 = { + "Lessie": "collie", + "Marlie": "labrador", + "Spike": "boxer", + "Buddy": "labrador", + "Milo": "labrador", + "Archie": "corgi", + "Tobby": "pit bull", + "Jack": "poodle", + "Lucy": "german shepherd", + "Bailey": "labrador" +} + +def remove_duplicates(): + pass \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 93d33ed..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest -pytest-env \ No newline at end of file diff --git a/tests/homework_1_1.py b/tests/homework_1_1.py deleted file mode 100644 index 5e17cb2..0000000 --- a/tests/homework_1_1.py +++ /dev/null @@ -1,126 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_1 import a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, result_sum, result_diff, result_multiplication, \ - result_division, result_division_floored, result_division_remainder, result_power, result_negative -import pytest - - -def test_sum(): - # Sum up a and b. Save the expression to the result_sum variable - if not result_sum: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert a + b == result_sum, f'Expected {a + b}, but got {result_sum}' - - -def test_diff(): - # Find the difference between c and d. Save the expression in the result_diff variable - if not result_diff: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert c - d == result_diff, f'Expected {c - d}, but got {result_diff}' - - -def test_multiplication(): - # Multiply e by f. Save the expression to the result_multiplication variable - if not result_multiplication: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert e * f == result_multiplication, f'Expected {e * f}, but got {result_multiplication}' - - -def test_division(): - # Divide g by h. Save the expression to the result_division variable - if not result_division: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert g / h == result_division, f'Expected {g / h}, but got {result_division}' - - -def test_division_floored(): - # Do floor division for i and j. Save the expression to the result_division_floored variable - if result_division_floored == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert i // j == result_division_floored, f'Expected {i // j}, but got {result_division_floored}' - - -def test_division_remainder(): - # Calculate the remainder of k divided by l. Save expression to the result_division_remainder variable - if not result_division_remainder: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert k % l == result_division_remainder, f'Expected {k % l}, but got {result_division_remainder}' - - -def test_power(): - # Rise m to the power n. Save the expression to the result_power variable - if not result_power: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert m ** n == result_power, f'Expected {m ** n}, but got {result_power}' - - -def test_negative(): - # Convert an o variable to negative. Save the expression to the result_negative variable - if not result_negative: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert -o == result_negative, f'Expected {-o}, but got {result_negative}' diff --git a/tests/homework_1_2.py b/tests/homework_1_2.py deleted file mode 100644 index 6a90c79..0000000 --- a/tests/homework_1_2.py +++ /dev/null @@ -1,98 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_2 import a, b, c, d, e, f, result_1, result_2, result_3, result_4 -import pytest - - -def test_power(): - # Find the second power of a variable. Save the expression to result_1 variable - if not result_1: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert a ** 2 == result_1, f'Expected {a ** 2}, but got {result_1}' - - -def test_float(): - # Convert integer b to float. Save the expression to result_2 variable - if not result_2: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert float(b) == result_2, f'Expected {float(b)}, but got {result_2}' - - -def test_int(): - # Convert a float variable c to integer. Save the expression to result_3 variable - if not result_3: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert int(c) == result_3, f'Expected {int(c)}, but got {result_3}' - - -def test_int_math(): - # Sum up variables d and e and then multiply the total by f. Convert result to an integer and save the - # expression to result_4 variable - if not result_4: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert int((d + e) * f) == result_4 diff --git a/tests/homework_1_3.py b/tests/homework_1_3.py deleted file mode 100644 index d2fb92c..0000000 --- a/tests/homework_1_3.py +++ /dev/null @@ -1,93 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_3 import a, result_1, result_2, result_3 -import math -import pytest - - -def test_rounding(): - # Round a off to three decimal places. - if not result_1: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert round(a, 3) == result_1, f'Expected {round(a, 3)}, but got {result_1}' - - -def test_rounding_greater(): - # Round up result_2 to greater value. - if not result_2: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert math.ceil(5 / 2 * 6 + 1.25 - 4) == result_2, f'Expected {math.ceil(5 / 2 * 6 + 1.25 - 4)}, ' \ - f'but got {result_2}' - - -def test_rounding_less(): - # Round up result_3 to lesser value. - if not result_3: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert math.floor(8 / 3 * 5 + 4.75 - 7) == result_3, f'Expected {math.floor(8 / 3 * 5 + 4.75 - 7)},' \ - f' but got {result_3}' diff --git a/tests/homework_1_4.py b/tests/homework_1_4.py deleted file mode 100644 index d119d30..0000000 --- a/tests/homework_1_4.py +++ /dev/null @@ -1,108 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_4 import result_string_1, result_string_2, result_string_3, result_full_name, \ - first_name, last_name, result_full_name_length, result_ca_capital, result_planet -import pytest - - -def test_create_string(): - # Create three strings using three different methods. Save your result to result_string_1, result_string_2, - # result_string_3 variables - if result_string_1 == None or result_string_2 == None or result_string_3 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert type(result_string_1) is str - assert type(result_string_2) is str - assert type(result_string_3) is str - - -def test_create_full_name(): - # Enter your first and last name. Join them together with a space in - # between. Save a result in a variable result_full_name and - # save the length of the whole name in result_full_name_length variable. - if first_name == None or last_name == None or result_full_name == None or result_full_name_length == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert f'{first_name} {last_name}' == result_full_name - assert type(result_full_name) is str - assert len(f'{first_name} {last_name}') == result_full_name_length - assert type(result_full_name_length) is int - - -def test_create_capital(): - # Enter the capital city of California State in lower case. Change the case to title case. - # Save the result in result_ca_capital variable - if result_ca_capital == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert f'sacramento'.title() == result_ca_capital - - -def test_result_planet(): - # Enter the name of our planet. Change the case to upper case. Save the result in - # result_planet variable - if result_planet == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert f'earth'.upper() == result_planet - diff --git a/tests/homework_1_5.py b/tests/homework_1_5.py deleted file mode 100644 index 9610917..0000000 --- a/tests/homework_1_5.py +++ /dev/null @@ -1,93 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_5 import result_string_1, result_string_2, result_value, number, result_string_3, n, word -import pytest - - -def test_newline_string(): - # Change result_string_1 that 'very simple language' will be displayed on a new line - if result_string_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert 'Python is the\nvery simple language' or 'Python is the \nvery simple language' or \ - 'Python is the \n very simple language' == result_string_1 - - -def test_fix_string(): - # Change result_string_2 to print out the phrase: 'What does the word 'integer' mean' - if result_string_2 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert 'What does the word \'integer\' mean' == result_string_2 - - -def test_input_value(): - # Assign number variable to value "5" (as a string). Then rise the number to the power 3. - # Save the expression to result_value variable - if number == None or result_value == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_value == int(number) ** 3 - - -def test_multiplication_string(): - # Enter a random number, then save the value to n variable. - # Finally, you should repeat the variable "word" n times and save the value to result_string_3 - if n == None or result_string_3 == None or word == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert n * word == result_string_3 diff --git a/tests/homework_1_6.py b/tests/homework_1_6.py deleted file mode 100644 index 1ec0756..0000000 --- a/tests/homework_1_6.py +++ /dev/null @@ -1,74 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_1.homework_1_6 import temperature_fahrenheit, result_temperature -import pytest - - -def test_fahrenheit(): - # Write your first program. Enter the temperature right now in Fahrenheit in temperature_fahrenheit variable as - # a string (e.g. '75') and convert it to Celsius. - # !important you should save only number to result_temperature. Formula (32°F − 32) × 5/9 = 0°C - if temperature_fahrenheit == None or result_temperature == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert float((int(temperature_fahrenheit) - 32) * 5 / 9) == result_temperature - - - diff --git a/tests/homework_2_1.py b/tests/homework_2_1.py deleted file mode 100644 index aba52ab..0000000 --- a/tests/homework_2_1.py +++ /dev/null @@ -1,158 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_2.homework_2_1 import first_number, second_number, result_1, number_1, result_2, first_name, last_name, \ - result_3, number_2, result_4, age, result_5, month, result_month -import pytest - - -def test_two_numbers(): - # Enter two numbers. If the first one is greater than the second, save first number in result_1, - # otherwise save the second number to the result_1 variable. - if first_number == None or second_number == None or result_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if first_number > second_number: - assert result_1 == first_number - else: - assert result_1 == second_number - - -def test_number(): - # Enter a number in number_1 variable. If this number is 20 or - # # higher save “Too high” text to result_2, otherwise save “Thank you”. - if result_2 == None or number_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if number_1 >= 20: - assert result_2 == "Too high" - else: - assert result_2 == "Thank you" - - -def test_full_name(): - # Enter your first name and last name in first_name and last_name variables. If the length of your first name is under - # five characters, join them together (without a space) and save it to result_3 variable in upper case. If the length - # of the first name is five or more characters, save their first name in lower case in result_3 variable. - if first_name == None or last_name == None or result_3 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if len(first_name) < 5: - assert result_3 == f'{first_name}{last_name}'.upper() - else: - assert result_3 == f'{first_name}'.lower() - - -def test_number_between(): - # Enter a number between 10 and 20 (inclusive) and save number to number_2 variable - # If they enter a number within this range, save a message “Thank you” to result_4, otherwise a - # message “Incorrect answer” to result_4. - if number_2 == None or result_4 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if 10 <= number_2 <= 20: - assert result_4 == f'Thank you' - else: - assert result_4 == f'Incorrect answer' - - -def test_ages(): - # Enter your age. If you are 18 or over, save the message “You can vote” in result_5, - # if you are aged 17, save the message “You can learn to drive” in result_5 variable, - # if you are 16, save the message “You can buy a lottery ticket” in result_5, - # if you are under 16, save the message “You can go Trick-or-Treating” in result_5 variable. - if age == None or result_5 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if age < 16: - assert result_5 == "You can go Trick-or-Treating" - elif age < 17: - assert result_5 == "You can buy a lottery ticket" - elif age < 18: - assert result_5 == "You can learn to drive" - else: - assert result_5 == "You can vote" - - -def test_month(): - # Enter a number between 1 and 12, save this value to month variable. Find which month is it. - # (January, February, March, April, May, June, Jule, August, September, October, November, December) - # Write answer in result_month in lower case - if month == None or result_month == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if month == 1: - assert result_month == 'January'.lower() - if month == 2: - assert result_month == 'February'.lower() - if month == 3: - assert result_month == 'March'.lower() - if month == 4: - assert result_month == 'April'.lower() - if month == 5: - assert result_month == 'May'.lower() - if month == 6: - assert result_month == 'June'.lower() - if month == 7: - assert result_month == 'Jule'.lower() - if month == 8: - assert result_month == 'August'.lower() - if month == 9: - assert result_month == 'September'.lower() - if month == 10: - assert result_month == 'October'.lower() - if month == 11: - assert result_month == 'November'.lower() - if month == 12: - assert result_month == 'December'.lower() \ No newline at end of file diff --git a/tests/homework_2_2.py b/tests/homework_2_2.py deleted file mode 100644 index 4dca24b..0000000 --- a/tests/homework_2_2.py +++ /dev/null @@ -1,131 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_2.homework_2_2 import number, number_1, number_2, result_1, result_2, result_3, result_4, first_name, \ - last_name, random_number -import pytest - - -def test_number(): - # Enter a number between 1 and 20, save this value to number variable. - # If number is greater than 0 and less than or equal to 7, save the number * 10 to result_1. - # If number is greater than 7 and less than or equal to 15, save the result of floor division of the number divided by - # 3 to result_1 variable - # If number is greater than 15 and less than or equal to 20, save the number raised to the power 3 to result_1 - # Else save the text "Wrong value" to result_1 - if number == None or result_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if 0 < number <= 7: - assert result_1 == number * 10 - elif 7 < number <= 15: - assert result_1 == number // 3 - elif 15 < number <= 20: - assert result_1 == number ** 3 - else: - assert result_1 == "Wrong value" - - -def test_two_numbers(): - # Enter two numbers between 1 and 10, save this values to number_1 variable and number_2 variables. - # If number_1 and number_2 are greater than 0 and less than or equal to 5 save in the product of their multiplication - # to result_2 - # If one of the variables (number_1 or number_2) is greater than 5 and less than or equal to 10, - # but the other isn't save the sum of the two numbers to result_2 - # If both numbers are greater than 5 and less than or equal to 10, multiply their sum by 3 and save it to result_2 - # Else save the text "Wrong values, try again" to result_2 - if number_1 == None or number_2 == None or result_2 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if 0 < number_1 <= 5 and 0 < number_2 <= 5: - assert result_2 == number_1 * number_2 - elif (0 < number_1 <= 5 and 5 < number_2 <= 10) or (0 < number_2 <= 5 and 5 < number_1 <= 10): - assert result_2 == number_1 + number_2 - elif 5 < number_1 <= 10 and 5 < number_2 <= 10: - assert result_2 == (number_1 + number_2) * 3 - else: - assert result_2 == "Wrong values, try again" - - -def test_name_length(): - # Enter your first name and save it to first_name variable, - # then Enter last name and save it to last_name - # If first_name or last_name are shorter than 6 characters, save a full name (with a space between) to result_3 - # Else save first_name to result_3 as many times as length of last_name value - if first_name == None or last_name == None or result_3 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if len(first_name) < 6 or len(last_name) < 6: - assert result_3 == f'{first_name} {last_name}' - else: - assert result_3 == first_name * len(last_name) - - -def test_even(): - # Enter a random number. Save this value to random_number variable - # If this number is less 10 or greater than 99, save the text "Please, put in a number between 10 and 99" to result_4 - # If a number doesn't meet the first condition, find the remainder of random_value divided by 2. - # If it is 0, save the text "Even number" to result_4 , else save the message "Odd number" - if random_number == None or result_4 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - if random_number < 10 or random_number > 99: - assert result_4 == "Please, put in a number between 10 and 99" - else: - if random_number % 2 == 0: - assert result_4 == "Even number" - else: - assert result_4 == "Odd number" diff --git a/tests/homework_2_3.py b/tests/homework_2_3.py deleted file mode 100644 index 31356c5..0000000 --- a/tests/homework_2_3.py +++ /dev/null @@ -1,122 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_2.homework_2_3 import result_1, result_2, result_3, result_4, result_5, result_6, result_7, result_8, \ - result_9, string_1, string_2, string_3, string_4, string_5, string_6, string_7 -import pytest - -def test_indexes_1(): - # Save to variable result_1 the first character of string_1 variable. In result_2 save the last character - # of string_1. Use indexes. - if result_1 == None or result_2 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_1 == string_1[0] - assert result_2 == string_1[-1] - - -def test_indexes_2(): - # Save to variable result_3 string value from string_2 variable, written in reverse order, using concatenation. - if result_3 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_3 == string_2[5] + string_2[4] + string_2[3] + string_2[2] + string_2[1] + string_2[0] - - -def test_slicing_1(): - # Slice string string_3 from 5th to 20th (excluding 20th) character and save the result to variable result_4 - if result_4 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_4 == string_3[5:20] - - -def test_slicing_2(): - # Slice string string_4 from 10th character to the end of the string. Save only every second character to variable - # result_5 - if result_5 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_5 == string_4[10::2] - - -def test_slicing_3(): - # Slice string string_5 from the first to the last character, save only every forth character and - # save the result to variable result_6 - if result_6 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_6 == string_5[::4] - - -def test_slicing_4(): - # Slice string string_6 from the first to 14th (including 14th) character, save only every third character and save - # the result to variable result_7 - if result_7 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_7 == string_6[:15:3] - -def test_slicing_5(): - # Save to variable result_8 string value from string_7 variable, written in reverse order, using slicing. - if result_8 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_8 == string_7[::-1] - - -def test_range_1(): - # Create a range of numbers from 0 to 10 (excluding 10) and save it to result_9 variable - if result_9 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert result_9 == range(0,10) diff --git a/tests/homework_3_1.py b/tests/homework_3_1.py deleted file mode 100644 index 5d4a233..0000000 --- a/tests/homework_3_1.py +++ /dev/null @@ -1,104 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_3.homework_3_1 import result_1, name_1, result_2, number_1, name_2, result_3,\ - string_number_1, result_4 -import pytest - - -def test_print_name_three_times(): - # Enter your name, save it in name variable and save in result_1 variable your name repeated 3 times (use loops) - if result_1 == None or name_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert name_1 * 3 == result_1 - - -def test_print_name_number_times(): - # Modify your previous program so that it will enter your name (save it in variable name_2) and a number - # (save in variable number) and then save in result_2 variable your name repeated as many times as number_1 is - # (use loops) - if result_2 == None or name_2 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert name_2 * number_1 == result_2 - - -def test_sum_digits(): - # Enter a random string, which includes only digits. Write code which find a sum of digits in this string and save it - # into result_3 variable - result = 0 - if result_3 == None or string_number_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - for char in string_number_1: - result += int(char) - assert result == result_3 - - - - -# Create code which sums up all even numbers between 2 and 100 (include 100) and save it in result_4 variable -def test_sum_even_numbers(): - if result_4 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = 0 - for number in range(2, 101, 2): - result += number - assert result == result_4 - - diff --git a/tests/homework_3_2.py b/tests/homework_3_2.py deleted file mode 100644 index 4fa6a7c..0000000 --- a/tests/homework_3_2.py +++ /dev/null @@ -1,101 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_3.homework_3_2 import result_1, string_1, char_1, result_2, number_1, result_3, number_2 -import pytest - - -def test_counter(): - # Enter a random string in the variable string_1, then enter a character and save it in the variable char_1. - # Write code, which will count how many times your character is included in your string. - # Save result to result_1 variable - if result_1 == None or string_1 == None or char_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert string_1.count(char_1) == result_1 - - -def test_number_multiplication(): - # Enter a random number and save it in variable number_1. Then create code to multiply all the digits together - # and save result in the result_2 variable. - if result_2 == None or number_1 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = 0 - num_string = str(number_1) - length = len(num_string) - index = 0 - while index < length: - result *= int(num_string[index]) - index += 1 - assert result_2 == result - - -def test_number_reverse(): - # Enter a random number and save it in variable number_2. Then create code which will return - # a number with digits of number_1 in reverse order. Save it in result_3 variable - if result_3 == None or number_2 == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - num_string = str(number_2) - index = len(num_string) - result = '' - while index > 0: - result += num_string[index-1] - index -= 1 - assert result_3 == int(result) - diff --git a/tests/homework_5_1.py b/tests/homework_5_1.py deleted file mode 100644 index 78eaa72..0000000 --- a/tests/homework_5_1.py +++ /dev/null @@ -1,105 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_5.homework_5_1 import difference, division, function_1, temerature_convertor, taxi_fare -import pytest - - -def test_difference(): - # Difference - # Write a function, which will calculate the difference of these two numbers - if difference(10, 1) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert 10 - 1 == difference(10, 1) - - -def test_division(): - # Division - # Write a function, which will divide these two numbers - if division(2, 1) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert 2 / 1 == division(2, 1) - - -def test_function_1(): - # Function gets random number. If this number is more than ten, return the difference between 100 and this number, - # otherwise return this number multiplied by 10 - if function_1(20) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert 100 - 20 == function_1(20) - assert 5 * 10 == function_1(5) - - -def test_temerature_convertor(): - # Your function temerature_convertor gets the temperature in Fahrenheit, convert it to Celsius and return. - # Formula (32°F − 32) × 5/9 = 0°C - if temerature_convertor(10) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert (100 - 32) * 5 / 9 == temerature_convertor(100) - - -def test_taxi_fare(): - # Taxi Fare - # In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters travelled. - # Write a function that takes the distance travelled (in kilometers) as its only parameter and returns the total fare - # as its only result rounded by 2 digits. Write a program that demonstrates the function. - if taxi_fare(10) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - assert taxi_fare(10) == round(10 * 1000 / 140 * 0.25 + 4, 2) diff --git a/tests/homework_6_1.py b/tests/homework_6_1.py deleted file mode 100644 index a57dfb2..0000000 --- a/tests/homework_6_1.py +++ /dev/null @@ -1,182 +0,0 @@ -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT -# PLEASE, DON'T CHEAT - - -# THIS FILE HAS ANSWERS. USE IT ONLY WHEN YOU HAVE SUCCESSFULLY PASSED HOMEWORK TESTS - - -from lesson_6.homework_6_1 import swap_first_last, reverse_list, multiply_list_items, smallest_item_list, \ - remove_duplicates_list, longer_words_list, find_item_lists, list_to_string, count_items_list, even_items_list, \ - list_1, list_2, list_3, list_4, list_5, number_1, list_6, list_7, list_8, list_9, number_2, list_10, list_11 -import pytest - - -def test_swap_first_last(): - # You are given a list in list_1 variable, write a swap_first_last function to return a new list with - # the first and the last elements of the list swapped. - # Return this list - - if swap_first_last(list_1) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = list_1.copy() - result[0], result[-1] = result[-1], result[0] - assert swap_first_last(list_1) == result - - -def test_reverse_list(): - # You are given a list in list_2 variable, write a reverse_list function which creates a new list in reversed order. - # Return this list - if reverse_list(list_2) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = list_2.copy() - result.reverse() - assert reverse_list(list_1) == result - - -def test_multiply_list_items(): - # Create a list which contains only number items and save it to the list_3 variable. Then write multiply_list_items - # function to multiply all the items in a list. Return result of multiplication - if list_3 == None or multiply_list_items(list_3) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = 1 - for item in list_3: - result *= item - assert multiply_list_items(list_3) == result - - -def test_smallest_item_list(): - # Create a list which contains only number items and save it to the list_4 variable. Then write a smallest_item_list - # function to get the smallest number from a list. Return smallest element - if list_4 == None or smallest_item_list(list_4) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - min_1 = list_4[0] - for item in list_4: - if item < min_1: - min_1 = item - assert smallest_item_list(list_4) == min_1 - - -def test_remove_duplicates_list(): - # Given a list in list_5 variable, write a remove_duplicates_list function to remove duplicates from a list. - # Return new list without duplicates - if remove_duplicates_list(list_5) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = [] - for item in list_5: - if not item in result: - result.append(item) - assert remove_duplicates_list(list_5) == result - - -def test_longer_words_list(): - # You are given a list in list_6 variable.Enter an integer number and save it to number_1 variable, - # write a longer_words_list function which will return the list of words that are longer than number_1 - # from a given list of words. - if number_1 == None or longer_words_list(list_6, number_1) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = [] - for item in list_6: - if len(item) > number_1: - result.append(item) - assert longer_words_list(list_6, number_1) == result - - -def test_find_item_lists(): - # Given two lists in list_7 and list_8 variables. Write a function find_item_lists that takes two lists and returns - # True if they have at least one common member. - - - if find_item_lists(list_7, list_8) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = False - for item_1 in list_7: - if item_1 in list_8: - result = True - assert find_item_lists(list_7, list_8) == result - - -def test_list_to_string(): - # You are given a list in list_9 variable. Write a function list_to_string to convert a list of - # characters into a string. - - if list_to_string(list_9) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = ''.join(list_9) - assert list_to_string(list_9) == result - - -def test_count_items_list(): - # Given a list of numbers in list_10 and a number number_2, write count_items_list function which will count number of - # occurrences of number_2 in the given list - - if count_items_list(list_10, number_2) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = list_10.count(number_2) - assert count_items_list(list_10, number_2) == result - - -def test_even_items_list(): - # Given a list of numbers, write a function even_items_list to return new list which include all even numbers in - # given list. - - - if even_items_list(list_11) == None: - pytest.skip(f"You didn't finish this task. the result variable equals None") - result = [] - for item in list_11: - if item % 2 == 0: - result.append(item) - assert even_items_list(list_11) == result