Complete the code to get the multi-dimensional index of the flat index 5 in a 3x3 array.
import numpy as np index = np.unravel_index([1], (3, 3)) print(index)
The flat index 5 corresponds to the multi-dimensional index (1, 2) in a 3x3 array.
Complete the code to find the multi-dimensional index of flat index 14 in a 4x5 array.
import numpy as np pos = np.unravel_index([1], (4, 5)) print(pos)
Flat index 14 corresponds to position (2, 4) in a 4x5 array.
Fix the error in the code to correctly get the multi-dimensional index of flat index 7 in a 2x4x3 array.
import numpy as np pos = np.unravel_index([1], (2, 4, 3)) print(pos)
The flat index must be an integer, not a list, tuple, or string.
Fill both blanks to create a list of multi-dimensional indices for flat indices 0 to 5 in a 2x3 array.
import numpy as np indices = [np.unravel_index(i, [1]) for i in [2]] print(indices)
The shape is (2, 3) and flat indices go from 0 to 5, so range(6) is used.
Fill all three blanks to create a dictionary mapping flat indices to their multi-dimensional indices for a 3x2x2 array, for indices 0 to 11.
import numpy as np mapping = { [1]: [2] for i in [3] } print(mapping)
Each flat index i maps to its multi-dimensional index using np.unravel_index over range(12) for a 3x2x2 array.