Question: Python Problem: (Continue from https://www.chegg.com/homework-help/questions-and-answers/problem-1-computing-variance-problem-write-function-variance-takes-list-whose-elements-num-q44265873) Problem 2: Computing standard deviation For this problem, you will write a function standard_deviation that takes a list whose elements
Python Problem: (Continue from https://www.chegg.com/homework-help/questions-and-answers/problem-1-computing-variance-problem-write-function-variance-takes-list-whose-elements-num-q44265873)

Problem 2: Computing standard deviation For this problem, you will write a function standard_deviation that takes a list whose elements are numbers (they may be floats or ints), and returns their standard deviation, a single number. You may call the variance method defined above (which makes this problem easy), and you may use sqrt from the math library, which we have already imported for you. Passing an empty list to standard deviation should result in a ZeroDivisionError exception being raised, although you should not have to explicitly raise it yourself. [] from math import sqrt def standard deviation(data): ""Takes a list of numbers and returns their standard deviation.""" # YOUR CODE HERE raise NotImplementedError() [ ] ### Tests for standard deviation assert_almost_equal (standard deviation([3, 4, 5, 6]), 1.1180339887499) assert_almost_equal(standard_deviation([3, 4, 8]), 2.1602468994693) assert_almost_equal(standard_deviation((0.0, 0.0, 0, 0]), 0) assert_almost_equal(standard deviation([1.5, 2.5]), 0.5) assert_almost_equal (standard deviation([18, 19, 20, 21, 22]), 1.4142135623731) assert_almost_equal(standard_deviation([0, 43, 1, 1, 55]), 23.983327542274) try: standard deviation([]) except(ZeroDivisionError): pass Problem 2: Computing standard deviation For this problem, you will write a function standard_deviation that takes a list whose elements are numbers (they may be floats or ints), and returns their standard deviation, a single number. You may call the variance method defined above (which makes this problem easy), and you may use sqrt from the math library, which we have already imported for you. Passing an empty list to standard deviation should result in a ZeroDivisionError exception being raised, although you should not have to explicitly raise it yourself. [] from math import sqrt def standard deviation(data): ""Takes a list of numbers and returns their standard deviation.""" # YOUR CODE HERE raise NotImplementedError() [ ] ### Tests for standard deviation assert_almost_equal (standard deviation([3, 4, 5, 6]), 1.1180339887499) assert_almost_equal(standard_deviation([3, 4, 8]), 2.1602468994693) assert_almost_equal(standard_deviation((0.0, 0.0, 0, 0]), 0) assert_almost_equal(standard deviation([1.5, 2.5]), 0.5) assert_almost_equal (standard deviation([18, 19, 20, 21, 22]), 1.4142135623731) assert_almost_equal(standard_deviation([0, 43, 1, 1, 55]), 23.983327542274) try: standard deviation([]) except(ZeroDivisionError): pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
