Python Examples

Example 1:

for i in range(4):

    turtle.forward(50)

    turtle.right(90)

Example 2: (let this one play for a while!)

turtle.pencolor("blue")

 

for i in range(50):

    turtle.forward(50)

    turtle.left(123) 

    

turtle.pencolor("red")

for i in range(50):

    turtle.forward(100)

    turtle.left(123)

Example 3:

dot_distance = 25

width = 5

height = 7

 

turtle.penup()

 

for y in range(height):

    for i in range(width):

        turtle.dot()

        turtle.forward(dot_distance)

    turtle.backward(dot_distance * width)

    turtle.right(90)

    turtle.forward(dot_distance)

    turtle.left(90)

Example 4:

turtle.speed(10)

 

for i in range(180):

    turtle.forward(100)

    turtle.right(30)

    turtle.forward(20)

    turtle.left(60)

    turtle.forward(50)

    turtle.right(30)

    

    turtle.penup()

    turtle.setposition(0, 0)

    turtle.pendown()

    

    turtle.right(2)

When ready to try it out:

Or, to try something different with Python, try Code Combat!