python 列表求和,最大值,最小值,乘积

numList = [1,2,3,4,5]   
 
sum = sum(numList)  #sum = 15
maxNum = max(numList) #maxNum = 5
minNum = min(numList) #minNum = 1
from operator import mul
prod = reduce(mul, numList, 1) #prod = 120 默认值传1以防空列表报错

  

posted @ 2015-10-28 09:16  arhatlohan  阅读(20966)  评论(0编辑  收藏  举报