def mean1(mylist):
mysum = 0
for i in range(len(mylist)):
mysum += mylist[i]
return float(mysum) / len(mylist)
def mean2(mylist):
mysum = 0
for value in mylist:
mysum += value
return float(mysum) / len(mylist)
def mean3(mylist):
return float(sum(mylist)) / len(mylist)
mylist = [1, 2, 3, 4]
print mean1(mylist), mean2(mylist), mean3(mylist)
ZGVmIG1lYW4xKG15bGlzdCk6CiAgIG15c3VtID0gMAogICBmb3IgaSBpbiByYW5nZShsZW4obXlsaXN0KSk6CiAgICAgIG15c3VtICs9IG15bGlzdFtpXQogICByZXR1cm4gZmxvYXQobXlzdW0pIC8gbGVuKG15bGlzdCkKCmRlZiBtZWFuMihteWxpc3QpOgogICBteXN1bSA9IDAKICAgZm9yIHZhbHVlIGluIG15bGlzdDoKICAgICAgbXlzdW0gKz0gdmFsdWUKICAgcmV0dXJuIGZsb2F0KG15c3VtKSAvIGxlbihteWxpc3QpCgpkZWYgbWVhbjMobXlsaXN0KToKICAgcmV0dXJuIGZsb2F0KHN1bShteWxpc3QpKSAvIGxlbihteWxpc3QpCgpteWxpc3QgPSBbMSwgMiwgMywgNF0KcHJpbnQgbWVhbjEobXlsaXN0KSwgbWVhbjIobXlsaXN0KSwgbWVhbjMobXlsaXN0KQ==