Bird
0
0

You want to create a 3D zero array with shape (2, 3, 4) and data type float64. Which code correctly does this?

hard📝 Application Q8 of 15
NumPy - Creating Arrays
You want to create a 3D zero array with shape (2, 3, 4) and data type float64. Which code correctly does this?
Anp.zeros((2, 3, 4), type='float64')
Bnp.zeros((2, 3, 4), dtype='float64')
Cnp.zeros(2, 3, 4, dtype='float64')
Dnp.zeros([2, 3, 4], dtype=float64)
Step-by-Step Solution
Solution:
  1. Step 1: Check shape argument format

    Shape must be a single tuple (2, 3, 4) for 3D array.
  2. Step 2: Verify dtype parameter

    Use dtype='float64' or dtype=float to specify data type.
  3. Step 3: Evaluate each option

    np.zeros((2, 3, 4), dtype='float64') uses correct tuple and dtype string. np.zeros([2, 3, 4], dtype=float64) uses list shape but dtype=float64 is undefined (needs quotes). np.zeros(2, 3, 4, dtype='float64') passes shape as multiple arguments, invalid. np.zeros((2, 3, 4), type='float64') uses 'type' instead of 'dtype', invalid.
  4. Final Answer:

    np.zeros((2, 3, 4), dtype='float64') -> Option B
  5. Quick Check:

    Shape tuple and dtype param correct [OK]
Quick Trick: Use tuple for shape and dtype='float64' for type [OK]
Common Mistakes:
  • Passing shape as multiple args
  • Using 'type' instead of 'dtype'
  • Omitting quotes on dtype string like float64

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes