Answer to Question #205473 in Python for Reoma Alurd

Question #205473

Define the following vectors and matrices:


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

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


10. What function would you use to find the value of j so that vec1[j] is equal to the smallest element in vec1?

 

11. What expression would you use to find the smallest element of the matrix

mat1?



1
Expert's answer
2021-06-11T05:06:35-0400
import numpy as np




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


#function vec1.argmin() returns the index of the smallest element in the vec1 array
j = vec1.argmin()
#expression mat1.min() returns the value of the smallest element in the mat1 array
smallest = mat1.min()


print(j)
print(smallest)

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