Python for datascience
Hey, can someone tell, why my code isn't good for this problem? #In order to find the variance I have to find the mean, after do (elem( element of the list) - mean) **2 for each element of the list, then to add all this results and divide them by the total number of elements. (at I understand so) Using the same vaccinations dataset, which includes the number of times people got the flu vaccine. The dataset contains the following numbers: never: 5 once: 8 twice: 4 3 times: 3 Calculate and output the variance. Declare a list with the data and use a loop to calculate the value. We will soon learn about easier ways to calculate the variance and other summary statistics using Python. For now, use Python code to calculate the result using the corresponding equation. My code: arr=[5,8,4,3]; x=0; x =(8*1+4*2+3*3+5*0)/20; y=0; sum=0; for i in range(len(arr)): y+=(arr[i]-x)**2; sum+=1; print (y/sum);