Functions and Modules

Image result for python functions and modules

Module: organized libraries of codes for related and useful functions and expressions

An extensive list of many useful modules can be found here.

Function: a chunk of code that can be called by name to perform a task

Functions often require arguments, specific data values, to perform their tasks. Arguments are known as parameters. Once the function has completed it’s task, it sends the result back to another part of the program, returning a value.

There are many functions that are built into Python by default. If the programmer is looking for more specific or intensive functions, they may need to import a module where that function is defined. Below is an image of IDLE when the programmer imports the math module and uses dir() to find a list of functions included in the module.

The image below is the results of help(math). It gives the same list as dir(math) but includes descriptions of what each function does as well. You can use help() on functions and modules alike.

Leave a comment