Python: Function
Define function
Here's a example of defining a function.
def ff(x, y): """ff(x, y) returns x+y.""" return x + y print(ff(3, 4)) # 7
A string immediately following the function def line is the function's documentation.
Return is optional
return is optional. If a function does not contain return statement, it returns None.
The pass statement
The pass statement does nothing.
Sometimes useful to create a do-nothing function, or empty class.
def ff(): pass print(ff()) # None