Continuing in our Python Preschool lessons (on how to draw basic things with code ^__^). …
Pen Up, Pen Down.
If we’re using Python and we want to STOP drawing, we can use a
… of course using your own turtle name instead of ‘kitten’. You can then move the turtle around (kitten.penup()
etc) and drop it down somewhere else on the canvas, with a kitten.forward(100)
kitten.pendown()
for loops
The syntax for a
loop is as follows: for
for i in range(100):
for example:
That draws whatever this is, repeatedly, as it cycled through the loop 100 times:
Neat! 100 is too many times, though. For this, at least. So I’m going to lower that to 10 times instead, and increase the pivot on the turtle to 160 to make that corner sharper. Add a fill .. and …
It makes a purrty star!
speed
Make your animation draw more quickly by adjusting the speed. 10 is the max:
flower.speed(10)
zoom zoom ZOOM!