Instagram
youtube
Facebook
Twitter

Find the Median Value of a NumPy Array

    A Find the Median Value of a NumPy Array
    
    Short Description of the Program:

    This program finds the median value from a NumPy array using the np.median() function.
    
     Explanation:

  • np.array()
    Creates a 2D array with numeric elements.

     
  • np.median(array_values)
    Calculates the median — the middle value when all elements are sorted.

     
  • print()
    Displays both the array and the median value.

Program:

array_values = np.array([[10, 25, 15], [40, 35, 20]])

median_value = np.median(array_values)

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

print("\nMedian Value of the Array:", median_value)