Skip to main content

11.5) Exercise 30 - Functions


Read the following functions, check you understand what they do, then type them into a program that you execute.

def nothing():
    """Do Nothing"""
    pass
nothing()

The pass command literally does nothing when it is executed. This is useful when you build the structure of your program and want to test it before it’s finished.

def message():
    """Print a message"""
    print 'This is a message to you.'
message()

It’s recommended to document your functions with a docstring; that’s the triple double quote string on the first line of the functions in the previous example.