Complete the code to find the index of the smallest value in the array.
import numpy as np arr = np.array([3, 1, 4, 1, 5]) index_min = np.[1](arr) print(index_min)
The np.argmin() function returns the index of the smallest value in the array.
Complete the code to find the index of the largest value in the array.
import numpy as np arr = np.array([10, 20, 30, 20, 10]) index_max = np.[1](arr) print(index_max)
The np.argmax() function returns the index of the largest value in the array.
Fix the error in the code to correctly find the index of the smallest value.
import numpy as np arr = np.array([7, 2, 5, 3]) index = np.argmin[1](arr) print(index)
The function call must use parentheses () to pass the array as an argument.
Fill both blanks to create a dictionary of indices of min and max values from the array.
import numpy as np arr = np.array([8, 6, 7, 5, 3, 0, 9]) result = {'min_index': np.[1](arr), 'max_index': np.[2](arr)} print(result)
np.argmin() and np.argmax() return the indices of the smallest and largest values respectively.
Fill both blanks to create a dictionary with keys as uppercase words and values as their indices if the index is greater than 2.
words = ['apple', 'banana', 'cherry', 'date', 'fig'] result = {word[1]: i for i, word in enumerate(words) if i [2] 2} print(result)
The dictionary comprehension uses word.upper() as the key, the index i as the value, and filters indices greater than 2.