Modules


        

Table of Contents

  1. Definition
  2. Examples

Definition

Python Modules are a file or a library containing built-in functions that will help us access specific types of functions. The prototype and the definitions of the functions are stored in their respective modules. Therefore, to access an inbuilt function in Python, you need to include the specific modules using the syntax import module_name.

Examples

These are some examples of the Python built-in modules.

Python Module Name Description Some Examples
math Mathematical functions math.sqrt(x), math.ceil(x), math.gcd(x)
calendar Calendar related functions iterweekdays(), itermonthdate(year,month)
array Efficient arrays of numeric values itemsize, buffer_info()
enum Support for enumerations Enum, property()
random Generate pseudo-random elements random.randint(), random.seed()
functools Higher-order functions and operations on callable objects functools.reduce(), functools.partial()
statistics Mathematical statistics functions mean(), mode(), median()