# Values from 5 to 20
a = np.arange(5, 20)
[ 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
numpy.ndarray
# Revere an array
b = a[::-1]
array([19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5])
c = np.array([[2, 3], [5, 89]])
[[ 2 3]
[ 5 89]]
[[ 5 89]
[ 2 3]]
[[1. 0. 0. 0. 0.]
[0. 1. 0. 0. 0.]
[0. 0. 1. 0. 0.]
[0. 0. 0. 1. 0.]
[0. 0. 0. 0. 1.]]
# Random
f = np.random.random((3, 1))
[[0.57782685]
[0.13940557]
[0.01241673]]
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
i = np.pad(g, pad_width=3, mode='constant')
[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 1. 1. 1. 1. 0. 0. 0.]
[0. 0. 0. 1. 1. 1. 1. 0. 0. 0.]
[0. 0. 0. 1. 1. 1. 1. 0. 0. 0.]
[0. 0. 0. 1. 1. 1. 1. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
j = np.pad(g, pad_width=1, mode='constant', constant_values=2)
[[2. 2. 2. 2. 2. 2.]
[2. 1. 1. 1. 1. 2.]
[2. 1. 1. 1. 1. 2.]
[2. 1. 1. 1. 1. 2.]
[2. 1. 1. 1. 1. 2.]
[2. 2. 2. 2. 2. 2.]]
[0.90819857 0.85455489 0.28167892 0.88489143 0.54545762 0.15966174
0.29479419 0.80940438 0.78830577 0.56276551]
[0.07001264 0.13921812 0.47192512 0.57821869 0.64253229 0.68100415
0.68742275 0.69785331 0.8750189 0.94492613]