Bird
0
0

What happens when you multiply a NumPy array by a scalar value?

easy📝 Conceptual Q1 of 15
NumPy - Array Operations
What happens when you multiply a NumPy array by a scalar value?
arr = np.array([1, 2, 3])
result = arr * 3

What is the result?
AThe array is repeated 3 times
BEach element in the array is multiplied by 3
CThe array elements are divided by 3
DAn error occurs because scalar multiplication is not allowed
Step-by-Step Solution
Solution:
  1. Step 1: Understand scalar multiplication on arrays

    Multiplying a NumPy array by a scalar multiplies each element by that scalar.
  2. Step 2: Apply multiplication to each element

    Elements [1, 2, 3] multiplied by 3 become [3, 6, 9].
  3. Final Answer:

    Each element in the array is multiplied by 3 -> Option B
  4. Quick Check:

    Scalar multiplication = element-wise multiply [OK]
Quick Trick: Scalar * array multiplies each element individually [OK]
Common Mistakes:
  • Thinking array repeats instead of element-wise multiply
  • Confusing multiplication with division
  • Expecting an error for scalar operations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes