Bird
0
0

Which of the following shapes can you use with np.full() to create a 1D array of length 5 filled with 9?

easy📝 Conceptual Q2 of 15
NumPy - Creating Arrays
Which of the following shapes can you use with np.full() to create a 1D array of length 5 filled with 9?
A(5,)
B(1, 5)
C(5, 1)
D(5, 5)
Step-by-Step Solution
Solution:
  1. Step 1: Identify 1D array shape

    A 1D array of length 5 has shape (5,), meaning one dimension with 5 elements.
  2. Step 2: Check other shapes

    Shapes (1, 5) and (5, 1) are 2D arrays, and (5, 5) is a 2D square array, so they don't match a 1D array.
  3. Final Answer:

    (5,) -> Option A
  4. Quick Check:

    1D array shape = (5,) [OK]
Quick Trick: 1D array shape always has one number in a tuple (n,) [OK]
Common Mistakes:
  • Using 2D shapes for 1D arrays
  • Confusing (5,) with (5,1)
  • Using (5,5) for 1D array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes