How to find Median [duplicate]
问题 This question already has an answer here: Finding median of list in Python 19 answers I have data like this. Ram,500 Sam,400 Test,100 Ram,800 Sam,700 Test,300 Ram,900 Sam,800 Test,400 What is the shortest way to fine the "median" from above data. My result should be something like... Median = 1/2(n+1), where n is the number of data values in the sample. Test 500 Sam 700 Ram 800 回答1: Python 3.4 includes statistics built-in, so you can use the method statistics.median: >>> from statistics