> I realise teachers have to test mastery of certain techniques, but they > seem to lack the imagination.
I agree; the problem here, I think, is that these homework questions often focus WAY too much on Python-specific features, rather than on fundamental issues, and so the questions end up feeling very artificial. So the first question that says: > > In a file called string_stuff.py i have to write a function called > > frequencies that takes a string as a parameter and returns a > > dictionary where the keys are the characters from the string and each > > value is an integer indicating the number of times the key appeared in > > the string. has no human context whatsoever, so of course it's a useless homework problem. Why would someone want to take a useless histogram of a bunch of letters? What would be more interesting is putting it in context, say like: "We're writing a book report, but we notice that we use certain words a lot more than other words. It would be useful to get an idea of what words are being overused so we can get out our thesaurus out on those particular words. We need to know which words we're using, and how frequently we're using them..." The context has to be there for the problem to make sense: otherwise what often ends up happening is disattachment and disillusionment. And the result should be relevant and feel like a "real" thing to them, even if it is a simplification. And it doesn't have to be immediately useful for the student, just as long as that student sees that it might be useful to someone. And in this case, if we don't mention dictionaries initially, that's fine, because we can solve the problem with or without dictionaries. If we did want to force the use of dictionaries: 1. We can motivate it later by mentioning that we want to use the program on a term paper, and it's taking forever. 2. Or we can talk about how our friends have some other program that can plot histograms, but it expects to see a dictionary mapping items and their occurrence. Either way, there needs to be a reason, a "why" to these things. Unfortunately, it takes effort on a teacher's end to do this, but that's what they should be paid for! *grin* _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor