generated from mwc/lab_iteration
Kathryn Odell-Hamilton
Started out with repetitive code to draw shapes, then used "ranges" to simplfy code drawing shapes and print numbers (even, odd, multiples), and experimenting with a complicated set of ranges drawing tiles with patterns. Checkpoint 1 - Yes, at first it was difficult drawing squares using a for-loop. I understood the definition of "square" with a for-loop in range of 4, the 4 sides using once each, forward and right. I didn't realize that the sizes = [20, 20, 20, 20] needed to be included within the code where it tells "for size in sizes" the square size and move forward to draw the next square. I reviewed the Iteration documentation several times and online, docs.python.org/3/library/turtle.html. Also, I asked you for assistance and then it made sense. Checkpoint 2 - I liked using “ranges” to generate a sequence of numbers and simplifying repetitive code. - Defining the sizes for a def and range. Such as "def square(side_length)". I see it's reference in "forward(side_length)", but (side_length) it seems arbitrary and abstract. Is it how to best describe what the "def" is. Are we talking about the name and value? And then defined within a "for-loop" incorporating a "range"? Checkpoint 3 - Yes, I will write docstrings when writing programs. The docstrings good for writing multiple lines of information explaining the code function by using """ at the beginning and end of the lines instead of " for each line. -Docstrings were useful with typing the explanation in tile_grid.py and experimented information in tile.py files.
This commit is contained in:
11
tile_grid.py
11
tile_grid.py
@@ -10,7 +10,16 @@ from tile import fly
|
||||
def draw_tile_grid(width, height, tile_size, tile_function):
|
||||
"""Draws a (width x height) grid, with tile_function drawn on each tile.
|
||||
|
||||
(Your explanation here.)
|
||||
(The draw_tile_grid function is importing from the tile.py defined functions "draw_tile_outline" and
|
||||
draw_squiggle to repeat the individual elements, tiles.
|
||||
Within draw_tile_grid, you use a "range" to repeat the height and width for size and moving (fly) without
|
||||
drawing. Then using the definition of "return_to_x_origin" and "return_to_y_origin" to the next x and y
|
||||
coordinates to position the pen to draw the next tile or begin the next row.
|
||||
Just as important is "drawtiles.py" file that calls the arguments/parameters for user input of width,
|
||||
height, and size. Although, the if else statement is using the defintion "draw_tile" where the argument prompt
|
||||
is coming from the "tile.py" definition "draw_tile.
|
||||
The 3 python files, drawtiles.py, tile.py, and tile_grid.py are drawing functions from each file without
|
||||
having to repeat the code in each file. Complicated and intricate. It's functional.)
|
||||
"""
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
|
||||
Reference in New Issue
Block a user