This commit is contained in:
Manish 2023-06-06 08:21:16 +10:00
parent 29c9df875b
commit c4cc4a406b

View File

@ -1,8 +1,18 @@
import numpy as np
def calculate(list):
return calculations
def calculate(nums):
if len(nums) != 9:
raise ValueError("List must contain nine numbers.")
array = np.array(nums)
array = array.reshape((3, 3))
calculations = {
'mean': [array.mean(axis=0), array.mean(axis=1), array.mean()],
'variance': [array.var(axis=0), array.var(axis=1), array.var()],
'standard deviation': [
array.std(axis=0), array.std(axis=1), array.std()],
'max': [array.max(axis=0), array.max(axis=1), array.max()],
'min': [array.min(axis=0), array.min(axis=1), array.min()],
'sum': [array.sum(axis=0), array.sum(axis=1), array.sum()]
}
return calculations