An Introduction to Python For Undergraduate Engineers/Functions

From Wikibooks, open books for an open world
Jump to: navigation, search

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