<jupyter_start><jupyter_text>![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)  Drawing with TurtlesWe can have fun and create art by commanding turtles to move around the screen.This uses a Python library called **mobilechelonian**, which is based on code written by students at [MacEwan University](https://www.macewan.ca/) in Edmonton.  Turtle Commands`t.speed(integer)`* Speed of your turtle, 1-10 (hint set your speed to 10) `t.pendown()` or `t.penup()`* For drawing lines or not `t.right(degrees)` or `t.left(degrees)`* Turn turtle left or right by some degree `t.forward(units)` or `t.backward(units)`* Move your turtle forward or backward (units are in pixels) `t.pencolor(“color”)`* Set the color of your turtle’s line, e.g. “blue” `t.circle(r, degrees)`* Have turtle draw a piece of a circle of radius *r*, some number of degrees   Can you get your Turtle to draw this house? ![house](images/turtle-house.png)<jupyter_code>from mobilechelonian import Turtle #import the Turtle module from the mobilechelonian library
import math #this library will come in handy when making the roof, hint math.sqrt()
t = Turtle()
t.speed(10)
### enter your code below, use the turtle commands above such as t.forward(100) and t.right(90)
t.forward(100) #hint
t.right(90)
t.forward(100) #hint
t.right(90)
t.forward(100) #hint
t.right(90)
t.forward(100) #hint
t.right(90)
t.right(-45)
t.forward(100/math.sqrt(2)) #remember your 45-45-90 triangle formula!
t.right(90)
t.forward(100/math.sqrt(2)) #remember your 45-45-90 triangle formula!<jupyter_output><empty_output><jupyter_text>Now let's try to draw this flower with our Turtle ![flower](images/turtle-flower.png)  Start by drawing a box efficiently with a `for` loop<jupyter_code>from mobilechelonian import Turtle
t = Turtle()
t.speed(10)

for i in range(4): #enter a value for range, how many times do we need to repeat to draw a box?
    t.forward(100) #enter a unit value
    t.right(90) #enter a degree value<jupyter_output><empty_output><jupyter_text>Draw a box with a function<jupyter_code>from mobilechelonian import Turtle
t = Turtle()
t.speed(10)

def box(units): #def means define function, in this case our function is called box
    for i in range(4): #enter a value for range. hint: how many times do we need to repeat to draw a box?  
        t.forward(units)
        t.right(90) #enter a degree value
        
box(100) #enter a unit value for our box function. hint: how many units did we use above?<jupyter_output><empty_output><jupyter_text>Draw a flower with `def` and `for` loops<jupyter_code>from mobilechelonian import Turtle
t = Turtle()
t.speed(10)

def box(units):
    for i in range(4): #enter a value for range
        t.forward(units)
        t.right(90) #enter a degree value

for i in range(18): #360 degrees/20 degrees per iteration = 18 iterations
    box(100) #enter a unit value
    t.right(20)<jupyter_output><empty_output><jupyter_text>Add colours to our flower using a `list`<jupyter_code>colours = ["purple", "blue", "red"] #this is a python list
colours[1] #indexing in python starts at "0", so to call "red" use "0" and so on.
#let's print what this looks like.
for i in range(18): #remember our loop with 18 iterations?
    print(colours[i % 3], i % 3) #using the modulo operator leaves us with the remainder.
#now let's put it all together
from mobilechelonian import Turtle
t = Turtle()
t.speed(10)

def box(units):
    for i in range(4): #enter a value for range
        t.forward(units)
        t.right(90) #enter a degree value

colours = ["purple", "blue", "red"]   
for i in range(18):
    t.pencolor(colours[i % 3]) #new turtle command
    box(100) #enter a unit value
    t.right(20)<jupyter_output><empty_output><jupyter_text>Bonus Challenge: Try to draw this pointy flower ![flower](images/turtle-pointy-flower.png)<jupyter_code>### enter your code below. don't forget to import your turtle module!
from mobilechelonian import Turtle
t = Turtle()
t.speed(10)

def parallelogram(units): 
    for i in range(2):
        t.right(-15)
        t.forward(units)
        t.right(30)
        t.forward(units)
        t.right(165)
        
colours = ["purple", "red", "blue"]   
for i in range(18):
    t.pencolor(colours[i % 3]) #new turtle command
    parallelogram(100) #enter a unit value
    t.right(20)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11494775102226261, 'fraction_numerical': 0.02975920036347115, 'mean_word_length': 4.317632850241546, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '661653', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1462, 'n_words': 527, 'path': 'CallystoAndComputationalThinking/Turtles-Solution.ipynb', 'repo_name': 'lfunderburk/online-courses', 'size': '4402'}