← All Data Science with Python Certification Flashcard Decks

Data Science with Python NumPy Array Manipulation Flashcards

7 cards from real Data Science with Python Certification practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Data Science with Python NumPy Array Manipulation flashcards as text
  1. What does `np.broadcast_to(a, shape)` do?

    Answer: Returns a read-only view of the array broadcast to the given shape

    `np.broadcast_to` returns a read-only view of the array stretched to the target shape without copying data.

  2. Which function stacks 1-D arrays as rows into a 2-D array?

    Answer: np.vstack

    `np.vstack` stacks arrays vertically (row-wise), converting 1-D arrays into rows of a 2-D array.

  3. What is the result of `np.arange(10).reshape(2,5)[1, ::2]`?

    Answer: array([5, 7, 9])

    Row index 1 gives [5,6,7,8,9], and step-2 slicing starting at 0 yields elements at positions 0,2,4 → [5,7,9].

  4. Which attribute gives the total number of elements in a NumPy array?

    Answer: array.size

    `array.size` returns the total count of elements (product of all shape dimensions).

  5. What does `np.squeeze(a)` do?

    Answer: Removes axes of length one from the array's shape

    `np.squeeze` removes dimensions of size 1, reducing unnecessary singleton axes from the shape.

  6. How do you swap axes 0 and 1 of a 2-D NumPy array `a`?

    Answer: np.swapaxes(a, 0, 1)

    `np.swapaxes(a, 0, 1)` interchanges two specified axes, equivalent to a transpose for 2-D arrays.

  7. What does the `np.tile(a, reps)` function do?

    Answer: Constructs an array by repeating `a` the number of times given by `reps`

    `np.tile` repeats the entire array `a` along each axis as specified by `reps`, constructing a larger array.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy