Bird
0
0

Which of the following is a correct way to create a 2x2 NumPy array filled with zeros?

easy📝 Conceptual Q2 of 15
SciPy - Basics and Scientific Computing
Which of the following is a correct way to create a 2x2 NumPy array filled with zeros?
Anp.zeros((2, 2))
Bnp.ones(2, 2)
Cnp.array([0, 0, 0, 0])
Dnp.empty(2)
Step-by-Step Solution
Solution:
  1. Step 1: Recall the function to create zero arrays

    np.zeros(shape) creates an array of zeros with the given shape.
  2. Step 2: Check the shape argument

    Using (2, 2) creates a 2x2 array filled with zeros, matching np.zeros((2, 2)).
  3. Final Answer:

    np.zeros((2, 2)) -> Option A
  4. Quick Check:

    Zeros array creation = np.zeros((2, 2)) [OK]
Quick Trick: Use np.zeros with shape tuple for zero arrays [OK]
Common Mistakes:
MISTAKES
  • Using np.ones instead of zeros
  • Passing shape incorrectly
  • Using np.empty without initialization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes