Hi people, so far can get the values, just want to get done the final layout as requested. The dictionary doesnt show the key values plus the lists are shown in vertical and i want to set them as the challenge requires (each axes and flattened outputs horizontal and separated by a comma). Thanks very much
Your code so far
import numpy as np
a = [int(x) for x in input('Intro 9 int separated by a space: ').split()]
if len(a) < 9 or len(a) > 9:
print (‘List must contain nine numbers’)
else: # can be removed
#print(a) #
arr = numpy.asarray(a) #turn list into array/matrix
#print(arr) # can be removed
arr = arr.reshape((3, 3)) # np.arange(9).reshape((3, 3)) for generating generic array from 0 to 8
#print(arr)
m1 = print(np.mean(arr, axis=0))
m2 = print(np.mean(arr, axis=1))
m3 = print(np.mean(arr.flatten()))
thisdict = dict[(
(‘mean’, m1, m2, m3),
(‘variance’, [print(np.var(arr, axis=0)), print(np.var(arr, axis=1)), print(np.var(arr.flatten()))]),
(‘standard deviation’, [print(numpy. std(arr, axis=0)), print(numpy. std(arr, axis=1)), print(numpy. std(arr.flatten()))]),
(‘max’, [print(np.max(arr, axis=0)), print(np.max(arr, axis=1)), print(np.max(arr.flatten()))]),
(‘min’, [print(np.min(arr, axis=0)), print(np.min(arr, axis=1)), print(np.min(arr.flatten()))]),
(‘sum’, [print(np.sum(arr, axis=0)), print(np.sum(arr, axis=1)), print(np.sum(arr.flatten()))]),
)]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Challenge: Data Analysis with Python Projects - Mean-Variance-Standard Deviation Calculator
Link to the challenge: