def read_numbers(filename): file = open(filename, "r") numbers = [] for number in file: numbers.append(int(number)) file.close() return numbers def get_counts(data): counts = {} for val in data: if val in counts: counts[val] += 1 else: counts[val] = 1 return counts def print_counts(counts): for key in counts: print(str(key) + "\t" + str(counts[key])) def get_most_frequent_value(data): counts = get_counts(data) max_key = 0 max_value = -1 for key in counts: if counts[key] > max_value: max_key = key max_value = counts[key] return max_key def get_most_frequent(data): counts = get_counts(data) max_key = 0 max_value = -1 for key in counts: if counts[key] > max_value: max_key = key max_value = counts[key] return (max_key, max_value)