On Wed, 12 Apr 2006, Kaushal Shriyan wrote:
> I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap09.htm > I did not understood the below Section at all :( Hi Kaushal, Ok, let's trying starting somewhere else and see at what point you get stuck. It'll also give you a chance to practice what you do understand so far. Are you comfortable about being able to return things besides numbers or strings from a function? In particular, do you have any experience writing functions that return tuples? For example, could you write a function that takes two elements, and wraps its input in a tuple? Let's call this function something, like wrap(). We'd expect wrap() to do something like this: wrap(5, 6) --> (5, 6) wrap("hello", "world") --> ("hello", "world") Would you be able to write a definition of wrap()? Let's start from there and see if we can isolate where you're getting stuck. Also, if you are having trouble with How to Think Like a Computer Scientist, I wouldn't be ashamed; I'm not such a big fan of it myself anymore. You might want to take a look at the other tutorials on: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers --- I'm going to rant, but not at you, but at that particular tutorial you're reading. To the others on the list: frankly, I really do not like the approach that "How to Think like a Computer Scientist" uses in marching through all the concepts it tries to teach; in a critical eye, I would say that it's doesn't do such a good job in integrating concepts, nor does it have natural flow. Am I alone in thinking this? Chapter Nine seems especially problematic in terms of flow. It's as if they say: "Here are tuples, a data structure. You should learn them. Ok, next up: here's something else you have to learn called random numbers. They have nothing to do with those tuple things what we just talked about, but we have to hurry if we're going to finish covering all the things in the glossary." Maybe I'm just reading too pessimistically into it, but the tutorial just seems to go out of its way to avoid flowing one concept into another, but instead jolting the student across the landscape. When I read part of that section you pointed out, there's one particular thing I strongly disagree with, that is, when they throw a rocky curveball with the introduction of the "broken" swap() function: ######################################## def swap(x, y): # broken x, y = y, x ######################################## The issue they try to tackle here really has nothing to do with tuples. The same "bug" occurs with: ###### def broken_swap(x, y): t = x x = y y = t ###### or, for that matter: ###### def broken_double(x): x = x * 2 ###### So I'm actually not quite sure why the tutorial is trying to make a point about this. It's an issue that should have been touched on much earlier in Chapter Five or Six, when functions and "multiple assignment" were introduced, so mixing it in with the tuple stuff just seems off-track and deliberately bewildering. And mixing it in haphazardly here risks the student thinking: "does the issue here have anything to do with this 'immutability' thing I just read about a few paragraphs ago?" _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor