python更新平均值

 

def addToAverage(average, size, value):
    '''
    The following function adds a number to an average. average is the current average,
    size is the current number of values in the average, and value is the number to add
    to the average:
    '''
    return ((size-1) * average + value) / (size)

 

posted on 2021-09-06 22:14  一杯明月  阅读(60)  评论(0编辑  收藏  举报