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

  • برمجة بايثون

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

الأجوبة

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

Sample Output:

Average of the array elements:                                         
-0.0255137240796                                                       
Standard deviation of the array elements:                              
0.984398282476                                                         
Variance of the array elements:                                        
0.969039978542
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...