Greenies, I've stuck by you for so long and made so many excuses for the bad service, now I'll go to mojo bones or poppas. Carrie L. and 2 others voted for this review Useful 3
Functions[edit] A function, which can also be referred to as subroutine, procedure, subprogram or even method, carries out tasks defined by a sequence of statements called a statement block that need only be written once and called by a program as many times as needed to carry out the same task.
Function definitions are the second of several compound statements we will see, all of which have the same pattern: 1  A header line which begins with a keyword and ends with a colon. 2  A body consisting of one or more Python statements, each indented the same amount â 4 spaces is the Python standard â from the header line. Weâve already seen the for loop which follows this pattern. In a function definition, the keyword in the header is def, which is followed by the name of the function and some parameters enclosed in parentheses. The parameter list may be empty, or it may contain any number of parameters separated from one another by commas. In either case, the parentheses are required.