Write a NumPy program to find the index of the sliced elements as follows from a given 4x4 array.
import numpy as np x = np.reshape(np.arange(16),(4,4)) print("Original arrays:") print(x) print("Sliced elements:") result = x[[0,1,2],[0,1,3]] print(result)
Sample Output:
Original arrays: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]] Sliced elements: [ 0 5 11]
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