generated from mwc/lab_iteration
	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.
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
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."
 | 
						|
    draw_tile_outline(size)
 | 
						|
    draw_squiggle(size)
 | 
						|
 | 
						|
def draw_tile_outline(size):
 | 
						|
    pencolor("#350D03")
 | 
						|
    square(size)
 | 
						|
 | 
						|
def draw_squiggle(size):
 | 
						|
    pencolor("goldenrod")
 | 
						|
    pensize(3)
 | 
						|
    quarter_arc_left(size/2)
 | 
						|
    left(90)
 | 
						|
    quarter_arc_left(size/2)
 | 
						|
    penup()
 | 
						|
    backward(size)
 | 
						|
    pendown()
 | 
						|
    quarter_arc_left(size/2)
 | 
						|
    left(90)
 | 
						|
    quarter_arc_left(size/2)
 | 
						|
    penup()
 | 
						|
    backward(size)
 | 
						|
    pendown()
 | 
						|
    quarter_arc_left(size/2)
 | 
						|
    left(90)
 | 
						|
    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."
 | 
						|
    penup()
 | 
						|
    forward(distance)
 | 
						|
    pendown()
 | 
						|
 | 
						|
def square(size):
 | 
						|
    "Draws a square of side length `size`"
 | 
						|
    for side in range(4):
 | 
						|
        pensize(2)
 | 
						|
        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)
 |