""" Exercise 5.7 from "A primer on..." Create an array w and demonstrate how various slicing operations work. """ import numpy as np w = np.linspace(0, 3, 31) print(w[:]) #the entire array print(w[:-2]) #entire array except two last elements print(w[::5]) #Every 5th element print(w[2:-2:6]) #starting from 2, every 6th el. up to -2 """ Terminal> python slicing.py [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3. ] [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8] [0. 0.5 1. 1.5 2. 2.5 3. ] [0.2 0.8 1.4 2. 2.6] """