Python for datascience | Sololearn: Learn to code for FREE!


Python for datascience

Hello everyone, I follow the course Python for datascience. I want to submit my code for the vaccination dataset but it shows me an error. I don't understand why. Please help 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. 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. Hint: The variance is the average of the squared differences from the mean. The code: vac_nums = [0,0,0,0,0, 1,1,1,1,1,1,1,1, 2,2,2,2, 3,3,3 ] #your code goes here mean_vac_num = sum(vac_nums)/len(vac_nums) i=0 for value in vac_nums: i = i + (mean_vac_num -value )**2 variance = i/len(vac_nums) print(variance)

12/12/2021 6:29:26 PM


3 Answers

New Answer


What do you get as the output??


I've tried your code and it runs without error and passes the test.


Sorry for the late answer. I don't know why but now it works... Anyway thank you :D