Skip to main content
1 of 5
ctrl-alt-delor
  • 10.9k
  • 4
  • 26
  • 54

Order to teach looping constructs in a non ideal language

#In an ideal teaching language

If the language directly supports them then the order to teach looping constructs seems simple.

  • Infinite loop: forever.
  • Simple finite (bounded) loop: repeat n times.
  • Bounded loops: for i in list or for i = 1...6 (I am not sure which order these two should be in).
  • Simple unbounded: while condition
  • Complex loops: all the rest.

However often the teaching language does not directly support these. This may be an argument for choosing a different language for teaching programming.

#In the chosen language

For example in python, the first two have no direct support. We have to synthesise them e.g.

  • Infinite loop: while True:

Here we have to explain what is True (to do this we need to explain the 4th loop type), or tell student to ignore it for now.

  • Simple finite (bounded) loop: for n in range(5):

Here we have to explain range(5) (this involves teaching the 3rd loop type).

#The question

So the question is “what to do?”. Do we start with

  • Bounded loops: for i in list:
  • Bounded loops: for i in range(n):
  • Simple unbounded: while condition:

Or do we do it some other way?

ctrl-alt-delor
  • 10.9k
  • 4
  • 26
  • 54