Created
June 7, 2019 06:54
-
-
Save sbsatter/2fa09e9b14caacb4c78e7af3af3fd7fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
n = int(input()) | |
array = sorted(list(map(int, input().split()))) | |
# print(array) | |
mean = sum(array) / n | |
if n % 2 == 0: | |
n1 = n//2 | |
n0 = n1 - 1 | |
median = (array[n0] + array[n1])/2 | |
else: | |
median = array[n//2] | |
mode = dict() | |
key = 0 | |
occurrence = -1 | |
for i in array: | |
mode[i] = mode.get(i, 0) + 1 | |
(key, occurrence) = (key, occurrence) if occurrence >= mode[i] else (i, mode[i]) | |
# print(key, occurrence) | |
print(round(mean, 1), round(median, 1), key, sep='\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment