⁉️ Interview question
Given the following NumPy code snippet, what will be the output and why?
The output will be a 2x2 array where each element is incremented by 5: [[6, 7], [8, 9]]. This happens because NumPy automatically broadcasts the scalar value 5 to match the shape of the array, performing element-wise addition.
#️⃣ tags: #numpy #python #arrayaddition #broadcasting #interviewquestion #programming
By: t.iss.one/DataScienceQ 🚀
Given the following NumPy code snippet, what will be the output and why?
import numpy as np
arr = np.array([[1, 2], [3, 4]])
result = arr + 5
print(result)
#️⃣ tags: #numpy #python #arrayaddition #broadcasting #interviewquestion #programming
By: t.iss.one/DataScienceQ 🚀