Bird
0
0

Which of the following best describes what np.squeeze() does to a NumPy array?

easy📝 Conceptual Q2 of 15
NumPy - Array Manipulation
Which of the following best describes what np.squeeze() does to a NumPy array?
ARemoves all axes of size 1 from the array shape
BReverses the order of elements in the array
CAdds a new axis of size 1 at a specified position
DChanges the data type of the array elements
Step-by-Step Solution
Solution:
  1. Step 1: Understand squeeze behavior

    np.squeeze() removes axes with length 1, reducing dimensions.
  2. Step 2: Eliminate incorrect options

    Adding axes is done by expand_dims(), reversing elements or changing data type are unrelated.
  3. Final Answer:

    Removes all axes of size 1 from the array shape -> Option A
  4. Quick Check:

    np.squeeze() = remove size 1 axes [OK]
Quick Trick: Squeeze removes size 1 axes; expand_dims adds them [OK]
Common Mistakes:
  • Thinking squeeze adds axes
  • Confusing with flattening
  • Assuming it changes data type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes