Ans. In order to add a border to an array that is filled with 0s, we first make an array Z and initialize it with zeroes. We first import numpy as np.
Z = np.ones((5,5))
Then, we perform padding on it with the help of pad() function.
Z = np.pad(Z, pad_width=1, mode=’constant’, constant_values=0)
print(Z)
Leave a Reply