[Tutor] functions in Python

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Apr 18 19:13:30 CEST 2006


> New at this but the f(x) with the return statement passes the value back 
> to be used in something. The one with the print statement just prints 
> it. Correct me if I am wrong experts

> def f(x):
>   x = x + 1;
>   return x
>
> def g(x):
>   x=x + 1;
>   print x;


Hi Eric,

Yes, you've got it.  Just as a side note: no semicolons needed.  *wink*


Best of wishes to you!


More information about the Tutor mailing list