import numpy as np x = np.arange(1, 11) x x_row = x.reshape((1, -1)) x_row x_col = x[:, np.newaxis] x_col np.dot(x_col, x_row) x_row * x_row x_row * x_col