Array Indexing
Intermediate · Write the code · from NumPy Arrays: Create, Index, Slice, and Reshape
From the lesson: NumPy Arrays: Create, Index, Slice, and Reshape
Imagine you have a spreadsheet with a million rows of numbers and you need to multiply every single value by 2. With a regular Python list, you'd write a loop that visits each cell one by one. It works, but it's slow.
Read the lessonGiven the array data = np.array([100, 200, 300, 400, 500, 600]), print:
1. The first element
2. The last element (use negative indexing)
3. The element at index 3
import numpy as np
data = np.array([100, 200, 300, 400, 500, 600])
# Print the three elements
More NumPy Array exercises
- Create Your First NumPy ArrayIntermediate
- Array Factory FunctionsIntermediate
- Slice and DiceIntermediate
- Predict the ShapeIntermediate
- Matrix ExtractionIntermediate
- Fix the Reshape BugIntermediate
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz