当前位置: 首页 > >

python列表求*均数_python 计算list中*均值_python里的list求*均值

发布时间:

#最大数


def Get_Max(list):


return max(list)


#最小数


def Get_Min(list):


return min(list)


#极差


def Get_Range(list):


return max(list) - min(list)


#中位数


def get_median(data):


data = sorted(data)size = len(data)


if size % 2 == 0:


# 判断列表长度为偶数


median = (data[size//2]+data[size//2-1])/2


if size % 2 == 1:


# 判断列表长度为奇数


median = data[(size-1)//2]


return median


#众数(返回多个众数的*均值)


def Get_Most(list):


most=[]


item_num = dict((item, list.count(item))


for item in list)for k,v in item_num.items():


if v == max(item_num.values()):


most.append(k)


return sum(most)/len(most)


#获取*均数


def Get_Average(list):


sum = 0


for item in list:


sum += item


return sum/len(list)



友情链接: