11FUNCTIONS AND MODULES
A function is a reusable set of instructions that performs a specific task. When the function completes its task, the flow of execution returns to the proper place in the greater code structure. Modules are programs, usually comprising functions, that perform a task or group of related tasks. Whereas you can define functions in place, you must import modules into a Python program to use them.
Both functions and modules let you simplify code through the process of abstraction. Abstraction is the act of moving the details of some process into a seemingly simpler object away from the main routine. Later, you can perform the ...
Get Python Tools for Scientists now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.