|
|||||||||||
Home Products Download Tutorials
Web Ring/Links Contact |
Create a functionThe function definition begins by the reserved word def follow by the function name and its parameters between parentheses, ended by a : (colon)The first function's lines of code contain the help. There are between triples " (double quotes). It is better to create them each time. They will help the user or can use by documentation generator programs. The function must indent at the same level than the function comments. All variables define inside a function exist only inside the function. A function completes its execution by returning a value to the caller by the return statement. Example :
Default value for function's argumentsMake argument optional is done by assigns a default value to it, by adding the equal sign and the default value after the parameter's name. Remark: an optional parameter can never be follow by a non-optional parameter.Example :
|
|
|||||||||
|