Write a NumPy program to create a 3-D array with ones on the diagonal and zeros elsewhere
import numpy as np x = np.eye(3) print(x)
Sample Output:
[[ 1. 0. 0.] [ 0. 1. 0.] [ 0. 0. 1.]]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer