最大值max:
num=[1,2,3,4]
def L_max(numb):
one=numb[0]
for i in numb:
if i > one:
one = i
return one
print(L_max(num))
4
最小值min:
def L_min(numb):
one=numb[0]
for i in numb:
if i < one:
one = i
return one
print(L_min(num))
1
长度:
def L_len(numb):
n=0
for i in numb:
n+=1
return n
print(L_len(num))
4
平均值:
def L_avg(numb):
u=0
for i in numb:
u+=i
return u/L_len(num)
print(L_avg(num))
2.5
求和:
def L_sum(numb):
u=0
for i in numb:
u+=i
return u
print(L_sum(num))
10