Bird
0
0

Given the numpy array arr = np.array([10, 20, 30, 40, 50]), what is the output of arr[-3]?

medium📝 Predict Output Q13 of 15
NumPy - Indexing and Slicing
Given the numpy array arr = np.array([10, 20, 30, 40, 50]), what is the output of arr[-3]?
A20
B40
C30
D50
Step-by-Step Solution
Solution:
  1. Step 1: Understand negative index -3

    Negative index -3 means counting from the end: last is -1 (50), second last -2 (40), third last -3 (30).
  2. Step 2: Identify element at index -3

    The element at arr[-3] is 30.
  3. Final Answer:

    30 -> Option C
  4. Quick Check:

    arr[-3] = 30 [OK]
Quick Trick: Count backward: -1 last, -2 second last, -3 third last [OK]
Common Mistakes:
  • Counting negative index from start instead of end
  • Mixing up index -3 with positive index 3
  • Off-by-one errors in counting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes