NumPy - Indexing and Slicing
Which slice will select every second element from a NumPy array
arr starting from the first element?arr starting from the first element?arr[::2] means start at index 0, go to the end, and take every 2nd element.arr[1::2] starts at index 1, not 0. arr[2::2] starts at index 2. arr[:2] only takes first two elements.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions