how to create chess board numpy

Solutions on MaxInterview for how to create chess board numpy by the best coders in the world

showing results for - "how to create chess board numpy"
Andrea
06 Oct 2018
1import numpy as np
2
3a=np.array(([1,0]*4+[0,1]*4)*4).reshape((8,8))
4print(a)
5
6#
7[[1 0 1 0 1 0 1 0]
8 [0 1 0 1 0 1 0 1]
9 [1 0 1 0 1 0 1 0]
10 [0 1 0 1 0 1 0 1]
11 [1 0 1 0 1 0 1 0]
12 [0 1 0 1 0 1 0 1]
13 [1 0 1 0 1 0 1 0]
14 [0 1 0 1 0 1 0 1]]
15