You are viewing a single comment's thread. Return to all comments →
Python 3: Thanks to srious, wasn't able to figure out how to accept the input. Solution uses only numpy.
import numpy as np N=int(input()) X=list(map(int, input().split())) mean=np.mean(X) X.sort() if N%2!=0: median=X[N//2+1] else: median=np.mean([X[N//2-1],X[(N//2)]]) v,c = np.unique(X,return_counts=True) mode=v[c==c.max()].min() print("{0:.1f}".format(mean)) print("{0:.1f}".format(median)) print("{}".format(mode))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 0: Mean, Median, and Mode
You are viewing a single comment's thread. Return to all comments →
Python 3: Thanks to srious, wasn't able to figure out how to accept the input. Solution uses only numpy.