当前位置:   article > 正文

python列表查找值_在Python中查找列表平均值的5种方法

find the average of the list

python列表查找值

Hi Folks! In this article, we will have a look at the various ways to find the average of a list in a Python List.

嗨伙计! 在本文中,我们将介绍在Python List中查找列表平均值的各种方法

In general, an average is a value that represents a whole set of data items or elements.

通常,平均值是代表整个数据项或元素集的值。

Formula: Average = summation of numbers/total count.

公式:平均值=数字总和/总计数。



在Python中查找列表平均值的技巧 (Techniques to find the average of a list in Python)

Either of the following techniques can be used to calculate the average/mean of a list in Python:

以下任何一种技术均可用于计算Python中列表的平均值/均值:

  • Python mean() function

    Python mean()函数
  • In-built sum() method

    内置sum()方法
  • Python lambda and reduce() method

    Python Lambda和reduce()方法
  • Python operator.add() method

    Python operator.add()方法


1. Python mean()函数 (1. Python mean() function)

Python 3 has statistics module which contains an in-built function to calculate the mean or average of numbers. The statistics.mean() function is used to calculate the mean/average of input values or data set.

Python 3具有statistics module ,该statistics module包含一个内置函数来计算数字的均值或平均值。 statistics.mean() function用于计算输入值或数据集平均值/平均值

The mean() function accepts the list, tuple or data-set containing numeric values as a parameter and returns the average of the data-items.

mean()函数接受包含数值的列表,元组或数据集作为参数,并返回

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/360838
推荐阅读
相关标签
  

闽ICP备14008679号