Calculate the variance of an array using NumPy

In this python numpy program, we will calculate the variance of an array using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Calculate the variance of the array using np.var().
  4. Print the output.
				
					import numpy as np
age = np.array([20,25,21,23,26,27,26,30,24,26]) 

print("Variance: ",np.var(age))
				
			

Output :

				
					Variance:  7.76
				
			

calculate the standard deviation of an array.

calculate the cos angle of an array.

Leave a Comment