The Task is to find standard Deviation of a given array. Using Class and Methods. Since I'm new to classes and Objects So, I'm not getting what's the problem in the code.
Input: 10 40 30 50 20
class Mean:
def __init__(self,X):
self.mean=(sum(X))/len(X)
#return self.mean
class Deviation(Mean):
def deviation(self,X):
Mean.__init__(self,X)
m=Mean(X)
self.d=0
for i in X:
self.d = self.d + (i-m)**2
return self.d
class Standard_Deviation:
def display(self,X):
sd=pow((Deviation(X))/(len(X)),0.5)
return(sd)
X=list(map(int,input().rstrip().split()))
t=Standard_Deviation()
z=t.display(X)
print(z)
The expected result is 14.1 but I'm getting a TypeError.
Traceback (most recent call last):
File "Solution.py", line 29, in <module>
z=t.display(X)
File "Solution.py", line 24, in display
sd=pow((Deviation(X))/(len(X)),0.5)
TypeError: unsupported operand type(s) for /: 'Deviation' and 'int'