import numpy as np
# Create a 3D array
array = np.array([[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]])
# Access element 9
# Explanation : consider the above 3D array as a stacked 2D array with 2 layers
layer 0 :
[[1, 2, 3], [4, 5, 6]]
layer 1 :
[[7, 8, 9], [10, 11, 12]]
9 is in layer 1
Within that layer, pick the first row.
Then, take the third element in that row
element = array[1, 0, 2]
print(element) # Output: 9
This structure makes it easy to navigate, slice, and manipulate data in three-dimensional space.