InterviewSolution
Saved Bookmarks
| 1. |
Write a Numpy program to create a 3x3 identity matrix, i.e. diagonal elements are 1, the rest are 0. Replace all 0 to random number from 10 to 20 |
|
Answer» import numpy as np array1=np.identity(3) print(array1) x=np.where(array1==0) for i in x: array1[x]=np.random.randint(low=10,high=20) print(array1) |
|