Last modified on 3 February 2011, at 22:20

An Introduction to Python For Undergraduate Engineers/Functions

Functions are declared with the def keyword, followed by the function’s prototype, a colon, and the body of the function which is indented. For instance

def foo(bar):
    print(bar)
    return bar