Learn
Introduction to Statistics with NumPy
NumPy and Standard Deviation, Part II

As we saw in the last exercise, knowing the standard deviation of a dataset can help us understand how spread out our dataset is.

We can find the standard deviation of a dataset using the Numpy function np.std:

>>> nums = np.array([65, 36, 52, 91, 63, 79]) >>> np.std(nums) 17.716909687891082

Instructions

1.

You’ve been asked to judge your town’s annual squash festival. The festival organizer gives you a list that includes all the weights for the two competitions that you’re judging: pumpkins and acorn squash.

Given the two data sets at the top of script.py, find the average weight for each competition and save them to the variables pumpkin_avg and acorn_squash_avg.

2.

Now, the rest of the judges want you to give them an idea of how representative the mean values are in relation to the entirety of the submissions. Calculate the standard deviation for each of the datasets to find and save them to the variables pumpkin_std and acorn_squash_std. Print them to the console to see their values.

3.

Determine the squash dataset that has the greater standard deviation and save it to the variable winner.

Folder Icon

Sign up to start coding

Already have an account?