Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to input a list to calculate the average value of python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "python how to input a list to find the average". In daily operation, I believe many people have doubts about how to input a list to find the average in python. Xiaobian consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful for everyone to answer the question of "how to input a list to find the average". Next, please follow the editor to study!

For mathematical operations, averaging is a relatively common operation. So in the python list, we also have an average operation to find the elements in it.

Method description

1. The mean () function takes a list, tuple, or dataset containing values as parameters and returns the average of the data items.

2. Grammar

Mean (data-set/input-values)

3. The parameter is axis. Take m * n matrix as an example:

Axis does not set a value, but calculates the average value of the number of MFN and returns a real number.

Axis = 0: compress rows, calculate the mean of each column, and return 1 * n matrix

Axis = 1: compress the column, calculate the average of each row, and return m * 1 matrix

Example

From numpy import * a = [52pr 69rec 355je 89je 15je 34] b = mean (a) print (b) at this point, the study on "how to input a list to find the average" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report