I think your looking at it too literally Joseph. Rather than any one example, think of a function as a block of code that is used in more than one place in your program. The x + y block of code is just a simplistic representation, intended to illustrate without the distracting complications of a more involved algorithm.

Functions are also useful (even necessary) in various approaches to problem solving. If you need an example one might be the recursive matrix solution approach I posted a link to in another post to this list.

Lee C


On Apr 17, 2005, at 12:29 PM, Joseph Quigley wrote:

Hi all,
Another function question.....

def bar(x, y):
        return x + y

bar(4, 5)

So I can put anything I want in there. What good is a function like that?
Of course I know about.
def foo():
print "Hello all you who subscribe to the Python Tutor mailing list!"


So what do you use the
def bar(x, y):
        return x + y

bar(4, 5)

functions for? (I just need a simple example)
Thanks,
        Joe

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to