Files
lab_iteration/tile.py
cramsey 93e1fd9fef yes it was difficult to rewrite square() using a
for-loop. (checkpoint 1)
I found that I understood how to work the rangest the easiest out of all three checkpoints.
(checkpoint 2)
I will probably use docstrings in my future codes. (checkpoint 3)
2025-10-06 14:57:25 -04:00

58 lines
1010 B
Python

from turtle import *
def draw_tile(size):
"Draws one tile, which can be repeated to form a pattern."
draw_tile_outline(size)
draw_squiggle(size)
def draw_tile_outline(size):
pencolor("#dddddd")
square(size)
def draw_squiggle(size):
pencolor("black")
forward(size/4)
left(90)
forward(size/4)
right(90)
forward(size/3)
left(90)
forward(size/2)
left(90)
forward(size/3)
right(90)
forward (size/4)
left(90)
forward(size/4)
left(90)
fly(size/4)
fly(size/4)
left(90)
def fly(distance):
"Moves without drawing."
penup()
forward(distance)
pendown()
def square(size):
"Draws a square of side length `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)