We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Thank you! Here's my copy, using your solution, but with some refs:
importnumpyasnpfromscipyimportstatsn=int(input())data=sorted([int(i)foriininput().split()])data_mean=np.mean(data)# numpy's median function returns the average of the two medians if our data # has an even number of elements, as required:# https://numpy.org/devdocs/reference/generated/numpy.median.html?highlight=median#numpy.mediandata_median=np.median(data)# https://docs.python.org/3.4/library/statistics.html#statistics.mode# "If there is more than one such value, only the smallest is returned"data_mode=stats.mode(data)[0][0]# Print number with one decimal placesprint(data_mean)print(data_median)print(data_mode)
Cookie support is required to access HackerRank
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 →
Thank you! Here's my copy, using your solution, but with some refs: