Python Project 1

Just wondering if I’m on the right track here…


# importing library
import numpy 
 
# create list
myList = [0,1,2,3,4,5,6,7,8]
 
# convert list to array
npArray = numpy.array(myList)
 
# print list
print ("List: \n", myList)
 
newArray = npArray.reshape(3, 3)
# print array
print ("Array: \n", newArray)

newArray = calculate
def calculate():
    print("calculate")

calculate()

Your browser information: Firefox Nightly 86.0a1

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Mean-Variance-Standard Deviation Calculator

Link to the challenge:

It looks like you’re on the right track. I think the trickiest part was using reshape to convert it to a 3x3 matrix, which you’ve already done!

1 Like

Thank you, I tidied it up a bit more, I guess I’m wondering if i define the list before i create the function but i seem to have sorted that out

import numpy as np

a = np.array([0,1,2,3,4,5,6,7,8])
print(a)

a = a.reshape(3, 3)
print(a)