Data Analysis with Python Projects - Mean-Variance-Standard Deviation Calculator

Tell us what’s happening:
Hi, everyone,
I am taking this general course about Python.
The result of my code shows array[], array[]...,
though I am seeking a way not to show such words “array” but the result inside the bracelet directly.
Thank you all for reading.

Your code so far

        import numpy as np

def calculate(list):
  if len(list)<9:
   print("List must contain nine numbers.")
  else:
   a=np.reshape(list,(3,3))
  b=(np.mean(a,axis=0),np.mean(a,axis=1),np.mean(a))
  c=(np.var(a,axis=0),np.var(a,axis=1),np.var(a))
  d=(np.std(a,axis=0),np.std(a,axis=1),np.std(a))
  e=(np.max(a,axis=0),np.max(a,axis=1),np.max(a))
  f=(np.min(a,axis=0),np.min(a,axis=1),np.min(a))
  g=(np.sum(a,axis=0),np.sum(a,axis=1),np.sum(a))
  calculations={  'mean': [b],'variance': [c],'standard deviation': [d],'max': [e],'min': [f],'sum': [g] }
  return calculations
print(calculate([2,6,2,8,4,0,1,5,7]))

Your browser information:

Challenge: Mean-Variance-Standard Deviation Calculator

Link to the challenge:

So, you get for example 'mean': [(array([3.66666667, 5. , 3. ]), array([3.33333333, 4. , 4.33333333]), 3.888888888888889)] , the outer square parenthesis is because you have written 'mean': [b], removing the square parenthesis you get instead 'mean': (array([3.66666667, 5. , 3. ]), array([3.33333333, 4. , 4.33333333]), 3.888888888888889) - the square parenthesis

the rest is because of what the value of b is
add print(b) and you get (array([3.66666667, 5. , 3. ]), array([3.33333333, 4. , 4.33333333]), 3.888888888888889)
if you don’t want that you need to change the value of b


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you for the advice!!

you can convert array to list like this :

b = [(np.mean(a,axis=0)).tolist(),(np.mean(a,axis=1)).tolist(),np.mean(a)]