Make a 5x5 BlockGrid
with your favorite color (from the "Colors" notebook)
and assign it to a variable called grid
.
Change the color of the block in the third row and fourth column.
Change the color of the block in the lower-right corner of the grid.
Use negative indexing to change the color of the block in the second row and first column.
Use a for
loop to change the color of every block in your grid.
Use a for
loop and an if
statement to change the color of every block
in the fourth column of your grid.
Augment your code from Exercise 6 with an elif
and an else
to change the
color of all blocks in your grid. But make the second column red, the
third column green, and all the other blocks gold.
Use an if
with an or
to change the color of the blocks in the first
and fifth rows to black.
Use an if
with an and
condition to turn every block that is in the
fourth column AND black to blue.
Make a new 20 by 20 block grid. Use a for
loop with range
to change the
color of every block in the third, 10th, and 18th rows.
Use nested for
loops with range
to change the color of the bottom-left
quadrant of your 20 by 20 grid.
Try to get the same affects as in Exercises 10 & 11, but using slicing instead
of for
loops.
Write a function that takes a grid as input and returns a new grid with the colors inverted (e.g. white becomes black, black becomes white, yellow becomes ???).
Write a function that takes a grid and a color as input returns a new grid that is the input grid with an added border of the given color.
BONUS: Make the color input argument optional.
Write a function that can follow a list of directions
('up'
, 'down'
, 'left'
, 'right'
) along a path, changing the color of
blocks as it goes.
An example function definition:
def path_color(grid, path, starting_point, color):
...