Bird
0
0

Consider arr = np.array([10, 20, 30, 40, 50, 60, 70]). What is the result of arr[4:1:1]?

medium📝 Debug Q6 of 15
NumPy - Indexing and Slicing
Consider arr = np.array([10, 20, 30, 40, 50, 60, 70]). What is the result of arr[4:1:1]?
A[20, 30, 40, 50]
B[50, 40, 30]
CAn empty array because the step is positive but start > stop.
DAn error due to invalid slice parameters.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze slice parameters

    Start index is 4, stop index is 1, step is +1.
  2. Step 2: Understand slicing behavior

    With positive step, slicing moves forward; since start > stop, no elements are selected.
  3. Final Answer:

    An empty array because the step is positive but start > stop. -> Option C
  4. Quick Check:

    Positive step requires start < stop [OK]
Quick Trick: Positive step needs start < stop to select elements [OK]
Common Mistakes:
  • Expecting reversed elements with positive step
  • Assuming slice throws error
  • Confusing start and stop indices

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes