Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Problem: Please check the previous problem for given code: https://www.chegg.com/homework-help/questions-and-answers/problem-1-computing-variance-problem-write-function-variance-takes-list-whose-elements-num-q44265873?trackid=mNNPJfYB Problem 2: Computing standard deviation For this problem, you will write a function standard_deviation

Python Problem:

Please check the previous problem for given code: https://www.chegg.com/homework-help/questions-and-answers/problem-1-computing-variance-problem-write-function-variance-takes-list-whose-elements-num-q44265873?trackid=mNNPJfYB

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions