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/12/03 04:57:51
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)