[Edu-sig] Sample Lesson Plan

Kirby Urner pdx4d@teleport.com
Fri, 04 Feb 2000 08:26:25 -0800

>to write a loop from 1 to n; it seems better to write
>  for i in range(1, n+1):

Good point.

>Finally, is it a pedagogical device to start with recursion and then
>write a for loop?  I suppose tetra(n) is easily defined recursively:
>  def tetra(n):
>      if n <= 1: return n
>      else: return tetra(n-1) + tri(n)

Yes, recursive OK here too.  I was actually going to give
recursive and non-recursive forms for both the tri() and 
tetra() functions but forgot my intent.  But I _do_ think 
it pedagogically useful to not get hooked on either/or 
thinking here.

Thanks for the Python pointers.  Your use of range() is of 
course far better, although range(n+1)[1:] does have the 
"advantage" of introducing the : business (something that's 
fun to play with).