Skip to content

Instantly share code, notes, and snippets.

@sz-ashik440
Created September 20, 2016 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sz-ashik440/192bc22b18da0292832e65997a6787a7 to your computer and use it in GitHub Desktop.
Save sz-ashik440/192bc22b18da0292832e65997a6787a7 to your computer and use it in GitHub Desktop.
n = int(input())
x = [int(i) for i in input().strip().split(' ')]
#mean
print('{0:.1f}'.format(sum(x)/len(x)))
#mediun
sortX = sorted(x)
if len(x)%2!=0:
print('{0:.1f}'.format(sortX[len(x)/2]))
else:
print('{0:.1f}'.format((sortX[int(len(sortX)/2)] + sortX[int(len(sortX)/2)-1])/2))
#Mode
dic = {}
for i in x:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
modeValue = dic[max(dic, key=dic.get)]
mod = [key for key, value in dic.items() if value==modeValue]
print(sorted(mod)[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment