Tell us what’s happening:
I have done as per requirements but i am getting an error :
TypeError: unsupported operand type(s) for -: ‘dict’ and ‘dict’
can anyone help with this one…
Your code so far
def calculate(list):
if len(list)!=9:
raise ValueError("List must contain nine numbers.")
nine_arr=np.array(list).reshape(3,3)
calculations={
'mean':[np.mean(nine_arr,axis=0).tolist(),np.mean(nine_arr,axis=1).tolist(),np.mean(list)],
'varience':[np.var(nine_arr,axis=0).tolist(),np.var(nine_arr,axis=1).tolist(),np.var(list)],
'standard deviation':[np.std(nine_arr,axis=0).tolist(),np.std(nine_arr,axis=1).tolist(),np.std(list)],
'max':[np.max(nine_arr,axis=0).tolist(),np.max(nine_arr,axis=1).tolist(),np.max(list)],
'min':[np.min(nine_arr,axis=0).tolist(),np.min(nine_arr,axis=1).tolist(),np.min(list)],
'sum':[np.sum(nine_arr,axis=0).tolist(),np.sum(nine_arr,axis=1).tolist(),np.sum(list)]
}
return calculations
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0
Challenge Information:
Data Analysis with Python Projects - Mean-Variance-Standard Deviation Calculator