Ha! I like the egg metaphor + demo. One thing I would suggest is to change
the variable from "egg" to "egg_in_hand". People in my workshop seemed to
have the most trouble with the idea that each element was being assigned to
the variable name in the for loop. With "egg_in_hand", you can demonstrate
the assignment that's happening.

Either way, I like all the different applications of your metaphor. You can
teach programming *and* make a cake, all in one session!

Juan.

On Thu, Dec 3, 2015 at 9:01 PM, Ian Hawke <[email protected]> wrote:

> 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
>
_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org

Reply via email to