Learn how to add NumPy arrays using np.add() function and the + operator for element-wise addition of array elements.

Using an add method
To add values of two different arrays in Numpy, you should use the Numpy add method. Add function takes arrays as arguments.
np.add() performs element-wise addition: corresponding elements are added; use out parameter for in-place operations.
import numpy as np
my_array = np.array([10, 20, 30, 40, 50])
print(f"My array \n{my_array}")
my_second_array = np.array([50, 50, 50, 50, 50])
print(f"My second array \n{my_second_array}")
add_array = np.add(my_array, my_second_array)
print(f"My added arrays \n{add_array}")
sum_array = my_array + my_second_array
print(f"My summed arrays \n{sum_array}")

The + operator is syntactic sugar for np.add(); both np.add(a, b) and a + b perform identical element-wise addition.
Arrays don’t need identical shapes; NumPy’s broadcasting rules align dimensions (e.g., (3,1) + (1,4) → (3,4)).
np.add() returns new array; use out parameter: np.add(a, b, out=result) for in-place addition to existing array.
