Bird
0
0

What will be the output of arr[::-3] for arr = np.array([2, 4, 6, 8, 10, 12, 14])?

medium📝 Predict Output Q5 of 15
NumPy - Indexing and Slicing
What will be the output of arr[::-3] for arr = np.array([2, 4, 6, 8, 10, 12, 14])?
A[14 11 8]
B[14 8 2]
C[2 8 14]
D[14 12 10]
Step-by-Step Solution
Solution:
  1. Step 1: Understand negative step

    A negative step reverses the array and picks elements every 3 steps.
  2. Step 2: Select elements

    Starting from last element (14), then index 3 (8), then index 0 (2).
  3. Final Answer:

    [14 8 2] -> Option B
  4. Quick Check:

    Negative step reverses and skips elements [OK]
Quick Trick: Negative step slices backward skipping elements [OK]
Common Mistakes:
  • Ignoring negative step effect
  • Wrong start index
  • Miscounting step intervals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes