In this topic, we discuss how to easily Find mean of a numpy array in Python programming. Let’s explore how to Find mean of a numpy array in python program.
Find Mean Of A NumPy Array
Table of contents :
- Introduction
- Program to Find mean of a numpy array
- Output
- Conclusion
Introduction to Find Mean of a NumPy Array :
NumPy is a powerful library for numerical computations in Python. One of its basic statistical functions is calculating the mean (average) of an array. The mean is the sum of all elements divided by the number of elements.
Steps
Import NumPy Library
Create a NumPy Array
Calculate the Mean
Program to Find Mean of a NumPy Array :
import numpy as np
# Create a sample NumPy array
array = np.array([1, 2, 3, 4, 5])
# Calculate the mean
mean_value = np.mean(array)
# Print the mean
print(“Mean of the array:”, mean_value)
Output :
Mean of the array: 3.0
=== Code Execution Successful ===
Conclusion:
Finding the mean of a NumPy array in Python is straightforward using the np.mean function, which efficiently computes the average of array elements across specified axes or the entire array.