Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q5 of 15
NumPy - Indexing and Slicing
What will be the output of the following code?
import numpy as np
arr = np.array([[10, 20], [30, 40], [50, 60]])
print(arr[2, 1])
A30
B50
C60
D40
Step-by-Step Solution
Solution:
  1. Step 1: Locate element at row 2, column 1

    Row 2 is [50, 60], column 1 is the second element, which is 60.
  2. Step 2: Output the value

    print(arr[2, 1]) outputs 60.
  3. Final Answer:

    60 -> Option C
  4. Quick Check:

    arr[2,1] = 60 [OK]
Quick Trick: Remember zero-based indexing for rows and columns [OK]
Common Mistakes:
  • Mixing up row and column indices
  • Using 1-based indexing
  • Selecting wrong element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes