import random size(600,600) cols = 30 rows = 30 cells = [[True for x in range(cols)] for y in range(rows)] wsq = width/cols hsq = height/rows noStroke() for y in range(rows): for x in range(cols): cells[x][y] = bool(random.getrandbits(1)) for y in range(rows): for x in range(cols): if cells[x][y]: fill(255) else: fill(0) rect(x*wsq,y*hsq,width/cols,height/rows) print(cells)