[Edu-sig] teaching python using turtle module

Alf P. Steinbach alfps at start.no
Mon Nov 30 22:36:04 CET 2009


* Edward Cherlin:
> On Sun, Nov 29, 2009 at 11:34, Brian Blais <bblais at bryant.edu> wrote:
> 
>> After a bit of playing, I realized that I couldn't think of many exaples
>> which use turtle with conditional structures (if- and while- statements),
> 
> Repeat is used much more often. but of course we can provide examples
> of any behavior you like. I like to use the turtle to generate
> sequences, where I can use a conditional to stop when the turtle would
> go off the screen. Fibonacci numbers, for example, or exponentials.
> Similarly for spirals of various types. Simple cases like those are
> easy to do in TA, while more complex sequences could use Python. There
> are several fractal examples using loops provided with Sugar on a
> Stick, including variations on Siepinksi constructions, and the Koch
> Snowflake.

In ch 2 of

   <url: http://preview.tinyurl.com/ProgrammingBookP3>

I use a turtle-generated spiral as the first example of a while loop.

I haven't got that far yet with that chapter, but I halfway plan on including a 
turtle graphics solve-a-maze example, which would/will be an example of 
conditionals with the turtle as a kind of actor making decisions.


>> or
>> functions that return values, as opposed to "procedures" like:
>> def square(length):
>>     forward(length)
>>     right(90)
>>     forward(length)
>>     right(90)
>>     forward(length)
>>     right(90)
>>     forward(length)
>>     right(90)

Plotting a graph. Some examples of that in ch 2 of aforementioned URL.


Cheers & hth.,

- Alf



More information about the Python-list mailing list