One example that I've used in words, and want to try in reality:

Take an eggbox with one row of eggs.

for egg in eggbox:
    crack(egg)

and then take them out one at a time and crack them (into a jug, I guess).

Alternatively, number the eggs with a permanent marker from 0, and use this to display list access.

Main reason for doing this with an eggbox is that it extends to two dimensions, so the metaphor can extends to numpy array examples with two indices, which always seems to cause more issues.

Ian

On 03/12/2015 09:24, Karin Lagesen wrote:
The more I teach, the more I realize that I am not really able to convey what a for loop does to everybody. Do any of you have a metaphor or something that you use for teaching it? I explain about variables and collections, and the body of the loop, and I show examples, but I am still not able to get through all the time.

Karin

_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org


_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org

Reply via email to