Bird
0
0

What is the default behavior of np.sum() when the axis parameter is not specified?

easy📝 Conceptual Q1 of 15
NumPy - Aggregation Functions
What is the default behavior of np.sum() when the axis parameter is not specified?
AIt sums elements along the first axis (rows) only.
BIt sums all elements of the array into a single scalar value.
CIt sums elements along the last axis (columns) only.
DIt returns the original array without any summation.
Step-by-Step Solution
Solution:
  1. Step 1: Understand default axis behavior

    When axis is not given, np.sum() sums all elements in the array.
  2. Step 2: Result type

    The result is a single scalar value representing the sum of all elements.
  3. Final Answer:

    It sums all elements of the array into a single scalar value. -> Option B
  4. Quick Check:

    Default axis behavior = sum all elements [OK]
Quick Trick: No axis means sum everything into one number [OK]
Common Mistakes:
  • Assuming it sums along rows by default
  • Thinking it returns an array
  • Confusing axis with shape

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes