Project 7: Restaurant Price Slicer
Data Engineer
Builds on these lessons
Current Task
Objective
Slicing an array with start:stop or a step (start:stop:step) returns a range of elements, just like Python list slicing.
Task: given a prices array, print elements 1 through 3, the first 3 elements, and every other element.
index.py
import numpy as np
prices = np.array([12, 8, 15, 20, 9, 11])
print(prices[1:4])
print(prices[:3])
print(prices[::2])
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview