[Tutor] functions in Python

Adam adam.jtm30 at gmail.com
Mon Apr 17 18:02:07 CEST 2006


On 17/04/06, Payal Rathod <payal-python at scriptkitchen.com> wrote:
> Hi,
> I am now reading Alan's tut on Python, before that I have read a few other tuts too.
> But I am not getting functions exactly. I mean what is the difference between,
>
> def func():
>         ....
>
> and
>
> def func(x):
>         ....
>
> When to use which? (please do not say "returns a value" for I do not understand the meaning
> of the same)
>
> With warm regards,
> -Payal

The x is a name for a value that you pass in to the function. To call
the first function you would do
>>> func()

and the second function:
>>> func(5) # 5 is just an example it could be any value depending on
the function.


More information about the Tutor mailing list