• Save
  • Run All Cells
  • Clear All Output
  • Runtime
  • Download
  • Difficulty Rating

Loading Runtime

Create a function called std_dev_list.

This function will be passed a list of numbers and should return the sample standard deviation of the numbers in the list.

As a reminder, the equation for sample standard deviation is as follows:

Sample Standard Deviation Equation

Where:

  • s is the sample standard deviation
  • n is the sample size
  • x_bar is the mean of the sample
  • (x_i - x_bar)^2 is the squared deviation of a given point from the sample mean

To calculate the sample standard deviation, find the sum of the squared deviations of each data point from the mean and then divide by the sample size minus one: n-1. This will find the sample variance. Take the square root of this result (the sample variance) to get the sample standard deviation.

If you have completed the Variance of a List code challenge, then this challenge should be straightforward since the sample standard deviation is defined as the square root of the sample variance.

The final number that is returned by your function must be accurate to two decimal places, but does not need to be rounded to two decimal places.


Example:

std_dev_list([3,4,6,6,77,4,3,2])

Returns: 25.848114051125663

Reset Code