Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python *10.9 (Statistics: compute deviation) Exercise 5.46 computes the stand

ID: 3705530 • Letter: I

Question

In python

*10.9 (Statistics: compute deviation) Exercise 5.46 computes the standard deviation of numbers. This exercise uses a different but equivalent formula to compute the standard deviation of n numbers i -mean) + x2 deviation- I i- mean =- To compute the standard deviation with this formula, you have to store the individual numbers using a list, so that they can be used after the mean is obtained. Your program should contain the following functions: # Compute the standard deviation of values def deviation(x): # Compute the mean of a list of values def mean(x): Write a test program that prompts the user to enter a list of numbers and displays the mean and standard deviation, as shown in the following sample run:

Explanation / Answer

Hi,

Below is the python code-

from math import sqrt

def mean(data):

n = len(data)

if n < 1:

raise ValueError('mean requires at least one data point')

return sum(data)/n

def _ss(data):

c = mean(data)

ss = sum((x-c)**2 for x in data)

return ss

def deviation(lst):

"""returns the standard deviation of lst"""

mn = mean(lst)

variance = sum([(e-mn)**2 for e in lst]) / len(lst)

return sqrt(variance)

int_list = [float(x) for x in input("Enter integers:").split()]

print("The mean is" , mean(int_list))

print("The deviation is" , deviation(int_list))