Instagram
youtube
Facebook
Twitter

Find the Mean Value of a NumPy Array

    Find the Mean Value of a NumPy Array
     
     Short Description of the Program:

     This program calculates the mean (average) of all the elements in a NumPy array using the np.mean()                 function.
     
      Explanation:

  • np.array()
    Creates a 2D NumPy array with numerical data.

     
  • np.mean(array_values)
    Calculates the average value of all elements in the array.

     
  • print()
    Displays both the array and the computed mean value.

     

Program:

import numpy as np

array_values = np.array([[10, 20, 30], [40, 50, 60]])

mean_value = np.mean(array_values)

print("NumPy Array:\n", array_values)

print("\nMean Value of the Array:", mean_value)