Write a NumPy program to get the values and indices of the elements that are bigger than 10 in a given array
import numpy as np x = np.array([[0, 10, 20], [20, 30, 40]]) print("Original array: ") print(x) print("Values bigger than 10 =", x[x>10]) print("Their indices are ", np.nonzero(x > 10))
Sample Output:
Original array: [[ 0 10 20] [20 30 40]] Values bigger than 10 = [20 20 30 40] Their indices are (array([0, 1, 1, 1]), array([2, 0, 1, 2]))
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