+ 1

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)

12th Dec 2021, 6:29 PM
béa
3 Antworten
+ 2
I've tried your code and it runs without error and passes the test.
12th Dec 2021, 7:17 PM
Simon Sauter
Simon Sauter - avatar
+ 1
What do you get as the output??
12th Dec 2021, 7:17 PM
Reuben Nyirenda
Reuben Nyirenda - avatar
+ 1
Sorry for the late answer. I don't know why but now it works... Anyway thank you :D
25th Dec 2021, 9:15 AM
béa