Search This Blog

Sunday, August 28, 2016

Turtle with whileLoop

 Not being a turtle expert myself I wanted to use turtle to show most of the examples I can come up with. Remember that if you can do it in turtle then you can do it in PyCraft. Just with a specific block type. For instance here I can loop through block types instead of colors.

import turtle
t = turtle.Pen()
turtle.bgcolor('black')
colors = ["red", "yellow", "blue", "green"]

for x in range(10):
    x = 0
    while x <100:
        t.pencolor(colors[x%4])
        t.forward(x)
        t.left(91)
        x = x+1
        print(x)
           
    x = 0
    while x <100:
        t.pencolor(colors[x%4])
        t.forward(x)
        t.left(91)
        x = x+1
        print(x)

No comments:

Post a Comment