Bird
0
0

Which of the following is the correct syntax to reshape a NumPy array arr into 2 rows and 3 columns?

easy📝 Conceptual Q12 of 15
NumPy - Array Manipulation
Which of the following is the correct syntax to reshape a NumPy array arr into 2 rows and 3 columns?
Aarr.reshape(2[3])
Barr.reshape{2, 3}
Carr.reshape(2, 3)
Dreshape(arr, 2, 3)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct reshape syntax

    The correct syntax is array.reshape(dim1, dim2, ...) with dimensions as separate arguments or a tuple.
  2. Step 2: Evaluate options

    arr.reshape(2, 3) uses correct method call with separate arguments. arr.reshape(2[3]) has invalid syntax (missing comma). arr.reshape{2, 3} uses curly braces which is wrong syntax. reshape(arr, 2, 3) uses a function call without object which is invalid.
  3. Final Answer:

    arr.reshape(2, 3) -> Option C
  4. Quick Check:

    Use dot and parentheses with dims [OK]
Quick Trick: Use dot and parentheses with dims, no brackets [OK]
Common Mistakes:
  • Forgetting comma between dimensions
  • Using curly braces instead of parentheses
  • Calling reshape as a standalone function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes