Indexing means picking out a single element from an array by its position. Just like in Python, NumPy indices start at 0. For a 2-D array, you can pick an element using the form array[row, column].
import numpy as np
marks = np.array([65, 78, 90, 82])
print("First mark:", marks[0])
print("Last mark:", marks[-1])
student_scores = np.array([
[80, 75, 90],
[88, 92, 85]
])
print("Second student, third subject:", student_scores[1, 2])marks[0] grabs the first element. marks[-1] grabs the last one. For a 2-D array, student_scores[1, 2] grabs the second row, third column. Since indices start at 0, row 1 is actually the second row.
First mark: 65 Last mark: 82 Second student, third subject: 85Info
Once you've got a solid handle on indexing, you can pull exactly the values you need out of table data, image pixels, or matrix values.