Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion function_a.py
Original file line number Diff line number Diff line change
@@ -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__":
Expand Down
12 changes: 11 additions & 1 deletion function_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
4 changes: 2 additions & 2 deletions function_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))