generated from mwc/lab_iteration
I added loops that were similar to the given ex.
Checkpoint 1: - It wasn't really difficult. I initially wrote the loop based on the number of sides the square has but then noticed the input was size dependent and not shape. So I just used the number of inputs for the loop. Checkpoint 2: - I think the concept of range and the related function we use is pretty simple and I understood it pretty well overall. - My mind briefly wandered off to series while writing the odd function. I could probably figure out why that connection popped up in my mind and how to implement it if asked but it wasn't needed for this time. Checkpoint 3: - I definitely will utilize docstrings along with whitespaces to help making the code more legible and easier to follow. This doesn't only benefit people who are unfamiliar with my code but also it benefits me to keep track of my thoughts if I ever were to take a break from, or foresee editing my code.
This commit is contained in:
35
tile.py
35
tile.py
@@ -1,4 +1,5 @@
|
||||
from turtle import *
|
||||
from turtle import forward, left, right,backward, pencolor, pendown, pensize, penup, circle
|
||||
|
||||
|
||||
def draw_tile(size):
|
||||
"Draws one tile, which can be repeated to form a pattern."
|
||||
@@ -6,22 +7,35 @@ def draw_tile(size):
|
||||
draw_squiggle(size)
|
||||
|
||||
def draw_tile_outline(size):
|
||||
pencolor("#dddddd")
|
||||
pencolor("#350D03")
|
||||
square(size)
|
||||
|
||||
def draw_squiggle(size):
|
||||
forward(size/4)
|
||||
pencolor("black")
|
||||
pencolor("goldenrod")
|
||||
pensize(3)
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
quarter_arc_right(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_right(size/4)
|
||||
quarter_arc_left(size/2)
|
||||
penup()
|
||||
backward(size)
|
||||
pendown()
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
fly(size/4)
|
||||
quarter_arc_left(size/2)
|
||||
penup()
|
||||
backward(size)
|
||||
pendown()
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
fly(size)
|
||||
quarter_arc_left(size/2)
|
||||
penup()
|
||||
backward(size)
|
||||
pendown()
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
quarter_arc_left(size/2)
|
||||
left(90)
|
||||
fly(0)
|
||||
|
||||
def fly(distance):
|
||||
"Moves without drawing."
|
||||
@@ -32,6 +46,7 @@ def fly(distance):
|
||||
def square(size):
|
||||
"Draws a square of side length `size`"
|
||||
for side in range(4):
|
||||
pensize(2)
|
||||
forward(size)
|
||||
left(90)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user