Project Overview :

● NumPy is an essential module for carrying out data science operations efficiently.
● NumPystands for Numerical Python.
● The numpy mean function or np.mean() is used for computing the arithmetic mean of the input values.
● Arithmetic mean is the sum of the elements along the axis divided by the number of elements. The numpy median or np.median() function helps in finding the middle value of a sorted array.
Synatax: np.mean()
Synatax: np.median()

 
Requirements :
 

● Python
● VS code
● Library – numpy

 
Code :
 

import numpy as np a = np.array([[9, 7, 4, 7], [3, 2, 1, 6]]) print("Mean = " , np.mean(a)) print("Median = ",np.median(a))
 
Code Explanation :
 

● import numpy as np-- import numpy as np and use it in python. In command prompt or VS code terminal run the below pip command to install numpy library,
● pip3 install numpy # For Python version 3
● a = np.array([[9, 7, 4, 5], [3, 2, 1, 6]]) –> two dimensional array stored in the variable a.
● print(a) –> print the array
● Find the mean and median of the array, then print it.
● print("Mean = " , np.mean(a))
● print("Median = ",np.median(a))

 
Output :

●After running the code, output of the terminal as given below,




« Home

×