Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
SciPy - Integration with Scientific Ecosystem
What will this code print?
import numpy as np
arr = np.arange(5)
result = np.sum(arr * 2)
print(result)
A15
B10
C20
D30
Step-by-Step Solution
Solution:
  1. Step 1: Create array and multiply by 2

    arr = [0,1,2,3,4], arr * 2 = [0,2,4,6,8].
  2. Step 2: Sum all elements

    Sum = 0+2+4+6+8 = 20.
  3. Final Answer:

    20 -> Option C
  4. Quick Check:

    Sum of doubled array = 20 [OK]
Quick Trick: np.sum sums all elements after vectorized ops [OK]
Common Mistakes:
  • Summing before multiplying
  • Confusing np.sum with np.prod
  • Misunderstanding np.arange output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes