Question: #My python program will not run! I ' m not sure why import math #You may not import any libraries other than math def calculate
#My python program will not run! Im not sure why
import math
#You may not import any libraries other than math
def calculateself:
return sumselfdataset lenselfdataset
# Insert code to calculate and return the mean of the dataset.
class median:
def initself dataset:
self.dataset dataset
def calculateself:
sorteddata sortedselfdataset
n lensorteddata
if n :
mid sorteddatan
mid sorteddatan
return mid mid
else:
return sorteddatan
# Insert code to calculate and return the median of the dataset.
class stdev:
def initself dataset:
self.dataset dataset
def calculateself:
meanvalue mean selfdatasetcalculate
n lenselfdataset
squareddiffsum sumx mean for x in self.dataset
return math.sqrtsquareddiffsum n
# Insert code to calculate and return the sample standard deviation
# of the dataset.
class pstdev:
def initself dataset:
self.dataset dataset
def calculateself:
mean meanselfdatasetcalculate
n lenselfdataset
squareddiffsum sumx mean for x in self.dataset
return math.sqrtsquareddiffsum n
# Insert code to calculate and return the population standard
# deviation of the dataset.
data
meancalculator meandata
mediancalculator mediandata
stdevcalculator stdevdata
pstdevcalculator pstdevdata
printMean: meancalculator.calculate
printMedian: mediancalculator.calculate
printSample Standard Deviation:", stdevcalculator.calculate
printPopulation Standard Deviation:", pstdevcalculator.calculate
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
