[Tutor] Defining a function (Joseph Q.)
Liam Clarke
cyresse at gmail.com
Tue Apr 12 15:27:32 CEST 2005
>>> def foo(x):
... print x
...
>>> foo('hi')
hi
What goes in the brackets is simply the arguments that foo() works with.
>>>def foo(a,b):
... return a + b
>>> sum = foo(5,10)
>>>print sum
15
>>> conjun = foo("Hi ", "Dave")
>>>print conjun
Hi Dave
Good luck,
Liam Clarke
On Apr 12, 2005 12:23 PM, Joseph Quigley <cpu.crazy at gmail.com> wrote:
>
> Well, now I've learned what def is good for. But what could I put in the
> parenthesis of def foo():?
> Of course self is always available, but what would maybe def foo(number1):do? An error right? So I now repeat my self, what else besides self could I
> put in there?
>
> Thanks,
> Joseph
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
--
'There is only one basic human right, and that is to do as you damn well
please.
And with it comes the only basic human duty, to take the consequences.'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050413/aceec993/attachment.html
More information about the Tutor
mailing list