Creating Functions

def Statement

Functions are created using the def statement, with a syntax like the following:

def function_name(arguments):

The header line consists of the def keyword, the function name, and a set of arguments (if any). The remainder of the def clause consists of an optional but highly-recommended documentation string and the required function body suite. We have seen many function declarations throughout this text, and here is another:


def helloSomeone(who):
    'returns a salutory string customized with the input'
     return "Hello" + str(who)

You may also like...