Given a NumPy array Arr = np.array([[1, 2, 3], [4, 5, 6]]) What will be the…

2026

Given a NumPy array
Arr = np.array([[1, 2, 3], [4, 5, 6]])
What will be the output of Arr.shape ?

  1. A.

    (6,)

  2. B.

    (3, 2)

  3. C.

    (2, 3)

  4. D.

    (1, 6)

Attempted by 111 students.

Show answer & explanation

Correct answer: C

The NumPy array `Arr` is defined with 2 rows and 3 columns. The `.shape` attribute returns a tuple representing the dimensions in the order of (number of rows, number of columns). Consequently, for this 2x3 matrix structure, the output is `(2, 3)`.

Explore the full course: Rssb Senior Computer Instructor