Create an array of the integers from 10 to 50
np.arange(10,51)
Create an array of all the even integers from 10 to 50
np.arange(10,51,2)
Create a 3x3 matrix with values ranging from 0 to 8
np.arange(9).reshape(3,3)
Create a 3x3 identity matrix¶
np.eye(3)
Use NumPy to generate a random number between 0 and 1
np.random.rand(1)
Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution
np.random.randn(25)
Create an array of 20 linearly spaced points between 0 and 1:
np.linspace(0,1,20)
mat is a 2d array
Get the sum of all the values in mat
mat.sum()
Get the standard deviation of the values in mat
mat.std()
Get the sum of all the columns in mat
mat.sum(axis=0)
Comments
Post a Comment