from ipythonblocks import BlockGrid
grid = BlockGrid(10, 10, fill=(123, 234, 123))
grid
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
grid[5, 5] = WHITE
grid
Make the square in the upper right hand corner of the grid turn red.
for and if loops!
grid = BlockGrid(10, 10, fill=(123, 234, 123))
for i in range(10):
grid[i, i] = WHITE
grid
Make the rightmost column of blocks turn red.
# you can nest for loops
for i in range(10):
for j in range(10):
grid[i, j] = GREEN
grid
# if statements
for i in range(10):
for j in range(10):
if i == j - 1:
grid[i, j] = RED
grid
Make the center diagonal red, the diagonal above/to the right of it blue, and the diagonal below/to the left of it white.