Answer to Question #205476 in Python for Reoma Alurd

Question #205476

Define the following vectors and matrices:


vec1 = np.array([ -1., 4., -9.])

mat1 = np.array([[ 1., 3., 5.], [7., -9., 2.], [4., 6., 8. ]]


13. The function np.random.rand can be used to construct and fill vectors and matrices with random numbers. Use the help facility in Python to learn how to construct a 10 × 10 matrix named M filled with random numbers.


1
Expert's answer
2021-06-12T06:13:50-0400
# importing numpy library
import numpy as np 


vec1 = np.array([ -1., 4., -9.])
# vec1 is row vector displayed as 1 dimensional array


mat1 = np.array([[ 1., 3., 5.], [7., -9., 2.], [4., 6., 8. ]]) 
# mat1 is a square matrix with dimension of 3x3 where in each of 3 row contain 3 values
  
#construct a 10 × 10 matrix 
M = np.random.rand(10, 10)
  
print(M)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS