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