Write a program which allows the user to input a list of five numbers.Write a program which allows the user to input a list of five numbers,then tells them the smallest,largest and median of the numbers they have entered.Hint:use the .sort() method o
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/30 10:52:03
![Write a program which allows the user to input a list of five numbers.Write a program which allows the user to input a list of five numbers,then tells them the smallest,largest and median of the numbers they have entered.Hint:use the .sort() method o](/uploads/image/z/9710020-28-0.jpg?t=Write+a+program+which+allows+the+user+to+input+a+list+of+five+numbers.Write+a+program+which+allows+the+user+to+input+a+list+of+five+numbers%2Cthen+tells+them+the+smallest%2Clargest+and+median+of+the+numbers+they+have+entered.Hint%3Ause+the+.sort%28%29+method+o)
Write a program which allows the user to input a list of five numbers.Write a program which allows the user to input a list of five numbers,then tells them the smallest,largest and median of the numbers they have entered.Hint:use the .sort() method o
Write a program which allows the user to input a list of five numbers.
Write a program which allows the user to input a list of five numbers,then tells them the smallest,largest and median of the numbers they have entered.Hint:use the .sort() method of the list.
Write a program which allows the user to input a list of five numbers.Write a program which allows the user to input a list of five numbers,then tells them the smallest,largest and median of the numbers they have entered.Hint:use the .sort() method o
def largest(data):
return data[len(data)-1]
def smallest(data):
return data[0]
def median(data):
return sum(data)*1.0/len(data)
def calc(data):
data.sort()
print 'Largest: ' + str(largest(data))
print 'Smallest: ' + str(smallest(data))
print 'Median: ' + str(median(data))
if __name__ == '__main__':
data = [10,9,6,10,5,-1,7,18,9,7,2,3,0,10,23]
calc(data)