w3resource logo
Python Exercises

Python NumPy: Compute the average, variance, standard deviation of an array of 1000 elements

Python NumPy Math, Statistics, Trigonometry and Linear algebra: Exercise-20 with Solution

Write a Python program to create a random array with 1000 elements and compute the average, variance, standard deviation of the array elements.

Sample Solution:-

Python Code:

import numpy as np
x = np.random.randn(1000)
print("Average of the array elements:")
mean = x.mean()
print("Standard deviation of the array elements:")
std = x.std()
print("Variance of the array elements:")
var = x.var()

Sample Output:

Average of the array elements:                                         
Standard deviation of the array elements:                              
Variance of the array elements:                                        

Python Code Editor:

Improve this sample solution and post your code through Disqus