From 9a36d12b152af20d4d8d1b9e3dea4b890385c230 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Sep 2024 23:21:01 -0400 Subject: [PATCH] resubmitting --- __pycache__/tile.cpython-310.pyc | Bin 0 -> 1216 bytes __pycache__/tile_grid.cpython-310.pyc | Bin 0 -> 1941 bytes ranges.py | 9 ++++++--- square.py | 12 ++++-------- tile.py | 22 +++++++--------------- tile_grid.py | 14 +++++++++++++- 6 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 __pycache__/tile.cpython-310.pyc create mode 100644 __pycache__/tile_grid.cpython-310.pyc diff --git a/__pycache__/tile.cpython-310.pyc b/__pycache__/tile.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6e7aeb595c187e7e4cfa71dd10d6f68355b1fb67 GIT binary patch literal 1216 zcmah}&2AGh5VrR(+cZHGN`>HJ0hgfCs3$m72#H?F1x}Sv>h3tns+)D{b%+{)gj5~` zZuH9I_`-n$$}4a{%y`q%QUs1XGoH1_-^_fDZnv8Z$Jfu_2VVllzR}|1Kp%UCv)Vxc z40yp_kq!#J$03C11KSHAh6Hs84M{ib2i6|WsY0%{8~4EvOd_4AGSh`NE~$>D(kK&SSdX|CDJ?@3bX|Qp$IHoc<#K}NOa2}WDmn1G z%d$h@fdmkG&20EFg6I>rW1T^?+=X5L=hymdd?D`H3G^-F`v^dZCcOm#a`8bSv%|$B zv=>B*#U6@I;u_e~nKWRCt}ZInz`AHG?FjpJWULDZ#qnROK~dW{s|^$_p5kv~IqMbH zhxS~l&p9P;<5$a0*l$AGfL2RdZoJTMR3(Tb$SgtqN6sMWLKkDdrW3P<0bB!Z(6bUB zKni(fWtpizJ9i5=-oaTVD3T!MO>W3{2^-;}hWg&!L&GAH6TZt{H{bEICu4)Uher{F zSlwv;VAnq$DQe;fJrGq6N))Ob+L72N^6#4#hBMbuc=Se=L*>z%8|doLd$sFmFJ2Jt9Yr`jpwH;rMYdiF7=Xo z+*@0-w4&xg)54lMNWHRksYNy8r2Cd1D()&56$p?28}5;|m+gqW?Nf(bEV>MfEru;+|qH(|)RFc6;IDdT)^5B`$ zg=sY0R&q9*eG|h-NFOYWk2?PJe?8<&7C)E7ZQ!qBM_i`W1-!f0CQz*d2X~9RScx_!g@NpHYIqZ8?|`}@|ra= zHS*0XrI&s+%G)6>igBh|br|6D+JV?X;fBVjH zhyopc%BLm&@06zNx?!!&{A?DzuC9X3T zqkk*#JJ|XHy>o9w?vd;$+i8c9-L_BJ7d25%1#$w0aPkJ=pquz?M~`bGn@W96$lL_O OXo%!YM<0#)li|OtSrCZ; literal 0 HcmV?d00001 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):