I've taught basic programming to kids and in these cases it's always nice to have a metaphor with candy. So: Halloween.
def Halloween: plan costume get in costume go outside for house on street: walk to house ring doorbell get candy say thank you If you've already taught if statements, you can do if trick: run away screaming, else: take candy You can also add a candy_count variable to the loop. Might be too silly for adults, but thought I'd share it anyway. On Thu, Dec 3, 2015 at 8:25 AM, Steve Haddock <hadd...@mbari.org> wrote: > I use a shopping basket and then `for item in basket`. The fact that the > item could be a single thing or a carton of eggs (=list), which could also > be looped through, helps. > I think the point about not using `egg` as the variable name is extremely > import. If you say `for line in myfile` they think `line` is a magic word > that grabs a line and `word` or `letter` would act differently. > The main conceptual hang up seems to be how the variable gets reassigned > each time. > It is also not "proper convention" and freaks out CS people, but I like to > capitalize the variable names, so it is easier to distinguish special > Python words from arbitrary names. > -Steve > ----- q•b ----- > > > > On Dec 3, 2015, at 01:24, Karin Lagesen <karin.lage...@gmail.com> 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 > > Discuss@lists.software-carpentry.org > > > http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org > > _______________________________________________ > Discuss mailing list > Discuss@lists.software-carpentry.org > > http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org >
_______________________________________________ Discuss mailing list Discuss@lists.software-carpentry.org http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org