How to find mean in Python using NumPy

You can find the mean in Python using NumPy with the following code. If you want to learn Python then I will highly recommend you to read This Book. Mean is the average of numbers. It can be calculated as Mean = Sum of Numbers / Total Numbers but NumPy has a built-in method to find the mean.

How to find mean in Python using NumPy
How to find mean in Python using NumPy

Mean of a List

import numpy as np
a = [1,2,3,4,5,6]
print(np.mean(a))
#Output 3.5

Mean of NumPy Array

import numpy as np
c = np.array([1,2,3,4,5,6])
print(np.mean(c))
#Output 3.5

Mean of 2D NumPy Array

import numpy as np
d = np.array([[1,2,3],[4,5,6]])
print(np.mean(d))
#Output 3.5

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Top 10 Computer Vision Books with Python

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.