I am to create an array using only NumPy tools. There it is:
[[2 2 2 2 2]
[2 1 1 1 2]
[2 1 1 1 2]
[2 1 1 1 2]
[2 2 2 2 2]]
That is my code:
import numpy as np
x = np.ones((5, 5), dtype = int)
x[0, :] = 2
x[4, :] = 2
x[:, 0] = 2
x[:, 4] = 2
print(x)
I wonder if it is possible to create an array like this in an easier (shorter) way?