• + 0 comments

    This is my algoritmic solution in python. I just use math library to round floor for counting the median:

    import math`

    n = int(input())

    x = input().split(" ")

    for i in range(len(x)): x[i] = int(x[i])

    x.sort()

    print(sum(x)/n)

    if(n%2==0): print((x[int(n/2)-1]+x[int(n/2)])/2) else: print(x[math.floor(n/2)])

    occur = 0 high = 0 modus = x[0]
    for i in range(1, n): if (x[i] == x[i-1]): occur += 1 if occur > high: modus = x[i] high = occur else: occur = 0

    print(modus)

    `