Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import numpy as np
a1=np.array([10,20,30,40,50,60])
#Single index
print (a1[3])
#Output: 40
#Slice
print (a1[2:5])
#Output: [30,40,50]
#List of index
print (a1[[1,4]])
#Output: [20 50]
#Slice with step
print (a1[1::2])
#Output: [20 40 60]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment