diff --git a/function_a.py b/function_a.py index 0bc43c29..3b66319e 100644 --- a/function_a.py +++ b/function_a.py @@ -1,7 +1,21 @@ def most_common_value(number_list): """ returns the most common element of the list """ - pass + frequency_index = {} + max_frequency = -1 + most_common_value = None + for num in number_list: + if frequency_index.get(num): + frequency_index[num] += 1 + else: + frequency_index[num] = 1 + + if max_frequency < frequency_index[num]: + max_frequency = frequency_index[num] + most_common_value = num + + return most_common_value + if __name__ == "__main__": diff --git a/function_b.py b/function_b.py index e888b354..215ca8c2 100644 --- a/function_b.py +++ b/function_b.py @@ -7,7 +7,17 @@ def silly_sum(): the user enters 0, or the sum reaches or exceeds 1000 """ - pass + num = int(input('Please enter a number => ')) + sum = 0 + + while num != 0: + sum += num + if sum >= 1000: + break + + num = int(input('Please enter a number => ')) + + return sum if __name__ == "__main__": diff --git a/function_c.py b/function_c.py index deb1023c..5efcf2b4 100644 --- a/function_c.py +++ b/function_c.py @@ -3,8 +3,8 @@ def merge_lists(list_a, list_b): a combination of list_a and list_b without any duplicate elements. """ - pass - + return list(set(list_a) | set(list_b)) if __name__ == "__main__": print(merge_lists([1, 1, 2, 3], [3, 4, 5])) +