Just wanted to say thanks for the great suggestions!
Will try to incorporate and see what happens :)
karin
On 12/3/2015 4:23 PM, Tyson Whitehead wrote:
On December 3, 2015 10:24:44 AM 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.
How about starting with the unrolled version and then introducing for as a
better way to write it. For example
print "hi there, "bill"
print "hi there, "sue"
print "hi there", "bob"
Ask what is similar about all these? What is the underlying "template"? Try
and get them to identify something like
print "hi there", name
Then, in terms of this template, the above is
name="bill"
print "hi there", name
name="sue"
print "hi there", name
name="bob"
print "hi there", name
From there perhaps it isn't such a big stretch to go to
for name in ["bill","sue","bob"]:
print "hi there",name
especially if there is some way to step through this last one in a debug mode
so they can literally see what it is doing.
Cheers! -Tyson
_______________________________________________
Discuss mailing list
Discuss@lists.software-carpentry.org
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org