Python 3 Statistics compute deviation Sample output Enter nu

Python 3 Statistics compute deviation.

Sample output Enter numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2

The mean is 3.11

The standard deviation is 1.55738

10.9 I 0,9 (Statistics: compute de Exercise 5.46 computes the standard numbers. This exercise uses a but equivalent formwala to compute the standard deviation of n numbers, 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) numbers and displays Write a test program that prompts the user enter a list of sample run: to the mean and standard deviation, as shown in the following

Solution


from math import sqrt

# list is defined as given
List_number = [1.9, 2.5, 3.7, 2, 1, 6, 3, 4, 5, 2]


#this is to find the mean of the list given
def mean(l):
s = 0
for i in range(len(l)):
s += l[i]
   mean = (s / len(l))
return mean

#this is to find the deviation of the list given
def dev(l):
s = 0
mn = mean(l)
for i in range(len(l)):
s += pow((l[i]-mn),2)
return sqrt(s/len(l)-1)


#printing mean and deviation
print mean(List_number)
print dev(List_number)

Python 3 Statistics compute deviation. Sample output Enter numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2 The mean is 3.11 The standard deviation is 1.55738 10.9 I 0,9 (Sta

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site