Bird
0
0

Why does NumPy allow one dimension in reshape() to be -1?

hard📝 Conceptual Q10 of 15
NumPy - Array Manipulation
Why does NumPy allow one dimension in reshape() to be -1?
ATo create an empty dimension
BTo automatically calculate that dimension based on the array size
CTo reverse the array along that dimension
DTo indicate that dimension should be removed
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of -1 in reshape

    -1 tells NumPy to infer that dimension size automatically.
  2. Step 2: Check other options

    Options A, B, and C do not describe the behavior of -1 in reshape.
  3. Final Answer:

    To automatically calculate that dimension based on the array size -> Option B
  4. Quick Check:

    -1 in reshape = auto dimension [OK]
Quick Trick: Use -1 to let NumPy infer dimension size [OK]
Common Mistakes:
  • Thinking -1 removes or reverses dimension
  • Assuming -1 creates empty dimension

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes