Teaching the "range" function in Python 3

Terry Reedy tjreedy at udel.edu
Fri Jun 30 16:22:05 EDT 2017


On 6/30/2017 1:07 PM, Irv Kalb wrote:

> Thanks to everyone who responded to my question about teaching the range function.

range is a class, not a function in the strict sense.

Classes represent concepts.  Instances of classes represent instances of 
the concept. Range represent the concept 'arithmetic sequence', a 
sequence of numbers with a constant difference.  To form an arithmetic 
sequence, start with a number and keep adding a constant.

Surely, schoolkids still have experience doing this, counting up or down 
by a number: 0,3,6,9,12,15...; 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 
'liftoff'; 99 bottles of beer. Counting down from 100 by a larger number 
is an old challenge.  100, 97, 94, 91, 88/

> I particularly like the ideas of using the words "collection" and "sequence"- those seem to be very clear.
> 
> In my curriculum, I first go through a in detail discussion of the need for, the syntax of and the usage of lists.

'list' represents the more general concept 'mutable sequence of 
arbitrary information objects'.

-- 
Terry Jan Reedy




More information about the Python-list mailing list