Bird
0
0

You want to create a 3D NumPy array of shape (2, 3, 4) filled with the value 10. Which code correctly does this?

hard📝 Application Q8 of 15
NumPy - Creating Arrays
You want to create a 3D NumPy array of shape (2, 3, 4) filled with the value 10. Which code correctly does this?
Anp.full((2, 3, 4), 10)
Bnp.full([2, 3], 10)
Cnp.full(2, 3, 4, 10)
Dnp.full((2, 3), 4, 10)
Step-by-Step Solution
Solution:
  1. Step 1: Understand the shape for 3D array

    The shape (2, 3, 4) means 2 blocks, each with 3 rows and 4 columns.
  2. Step 2: Check correct np.full() syntax

    np.full((2, 3, 4), 10) uses a tuple for shape and the fill value 10 correctly. np.full([2, 3], 10) uses incomplete shape (2x3 instead of 2x3x4). Options C and D have wrong argument counts or shapes.
  3. Final Answer:

    np.full((2, 3, 4), 10) -> Option A
  4. Quick Check:

    Use tuple shape and fill value in np.full() [OK]
Quick Trick: Use tuple for shape even in 3D arrays [OK]
Common Mistakes:
  • Wrong argument count
  • Using incomplete shape
  • Incorrect shape tuple

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes