import numpy as np # Create a 4x4 array with all elements set to 0 array = np.zeros((4, 4)) # Set the border elements to 1 using slicing array[0,:] = 1 array[-1,:] = 1 array[:,0] = 1 array[:,-1] = 1 print(array)