Python Turtle Basics 2

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 kitten.penup() … of course using your own turtle name instead of ‘kitten’. You can then move the turtle around (kitten.forward(100) etc) and drop it down somewhere else on the canvas, with a kitten.pendown()

for loops

The syntax for a for loop is as follows:

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!

Leave a Comment