In NumPy, what is the result of the operation np.array([1, 2, 3]) + 5?
2026
In NumPy, what is the result of the operation
np.array([1, 2, 3]) + 5?
- A.
An error
- B.
[6, 7, 8]
- C.
[1, 2, 3, 5]
- D.
[5, 10, 15]
Attempted by 123 students.
Show answer & explanation
Correct answer: B
In NumPy, adding a scalar to an array performs element-wise addition. The operation np.array([1, 2, 3]) + 5 adds 5 to each element: 1+5=6, 2+5=7, and 3+5=8. The resulting array is [6, 7, 8].