A function is a block of reusable code that performs a single action. Functions enable applications to be modular.
Python provides many built-in functions like print(). You can also create your own functions. These are called user-defined functions.
To create a function in Python start with the keyword def followed by the function name and parentheses (). Input parameters should go within the parentheses. The code block starts with : and codes are indented. The code block ends with a return statement. ``` #!/usr/bin/env python
This is a function example
# Here we define the function def printThis(str): print str return
We can now call the function
printThis(“I want to print this text”) ```