diff --git a/__pycache__/tile.cpython-310.pyc b/__pycache__/tile.cpython-310.pyc new file mode 100644 index 0000000..6e7aeb5 Binary files /dev/null and b/__pycache__/tile.cpython-310.pyc differ diff --git a/__pycache__/tile_grid.cpython-310.pyc b/__pycache__/tile_grid.cpython-310.pyc new file mode 100644 index 0000000..709ccbb Binary files /dev/null and b/__pycache__/tile_grid.cpython-310.pyc differ diff --git a/ranges.py b/ranges.py index 2fa00d7..6b915c9 100644 --- a/ranges.py +++ b/ranges.py @@ -9,15 +9,18 @@ def print_all_numbers(maximum): def print_even_numbers(maximum): "Prints all even integers from 0 to maximum." - pass + for number in range(0, maximum, 2): + print(number) def print_odd_numbers(maximum): "Prints all odd integers from 0 to maximum." - pass + for number in range(1, maximum, 2): + print(number) def print_multiples_of_five(maximum): "Prints all integers which are multiples of five from 0 to maximum." - pass + for number in range(0, maximum, 5): + print(number) chosen_maximum = int(input("Choose a number: ")) print(f"All numbers from 0 to {chosen_maximum}") diff --git a/square.py b/square.py index c5f1cac..3878402 100644 --- a/square.py +++ b/square.py @@ -1,14 +1,10 @@ from turtle import * def square(side_length): - forward(side_length) - right(90) - forward(side_length) - right(90) - forward(side_length) - right(90) - forward(side_length) - right(90) + sides = [1, 2, 3, 4] + for side in sides: + forward(side_length) + right(90) sizes = [20, 40, 60, 80, 100] for size in sizes: diff --git a/tile.py b/tile.py index 697cf8e..87e64eb 100644 --- a/tile.py +++ b/tile.py @@ -1,23 +1,23 @@ from turtle import * +import math def draw_tile(size): "Draws one tile, which can be repeated to form a pattern." draw_tile_outline(size) - draw_squiggle(size) + draw_zigzag(size) def draw_tile_outline(size): pencolor("#dddddd") square(size) -def draw_squiggle(size): +def draw_zigzag(size): forward(size/4) pencolor("black") + left(45) + forward(math.sqrt(2)*size/2) left(90) - quarter_arc_right(size/4) - quarter_arc_left(size/4) - quarter_arc_left(size/4) - quarter_arc_right(size/4) - left(90) + forward(math.sqrt(2)*size/2) + left(45) fly(size/4) left(90) fly(size) @@ -34,11 +34,3 @@ def square(size): for side in range(4): forward(size) left(90) - -def quarter_arc_right(radius): - "Draws a quarter of an arc, turning to the right." - circle(-radius, 90) - -def quarter_arc_left(radius): - "Draws a quarter of an arc, turning to the left." - circle(radius, 90) diff --git a/tile_grid.py b/tile_grid.py index 72a0f43..cf7158d 100644 --- a/tile_grid.py +++ b/tile_grid.py @@ -10,7 +10,19 @@ 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 width, height, and tile_size are input when running the program + from the terminal. The tile_function determines the pattern drawn on the + tile, and when the tile_function argument is called, it passes and runs + the function draw_tile from tile.py, because it is the last function it + encountered...? + + The "for y in range(height):" calls a loop determined by the the number of + rows indicated by the height. The "for x in range(width):" calls a loop + determined by the number of columns indicated by the width. The program + draws a complete row, then stops drawing and returns to the horizontal + starting point and moves up one tile length. It returns to the origin at + the very end.) + """ for y in range(height): for x in range(width):