Member-only story

Interview question: What do you understand by module in Python?

Crystal X
3 min readApr 19, 2023

--

Python is a language that has built in modules and modules that can be made within a program.

Modular programming is the practice of segmenting a single, complicated coding task into multiple, simpler, easier-to-manage sub-tasks. We call these subtasks modules. Therefore, we can build a bigger program by assembling different modules that act like building blocks.

Putting modules of smaller chunks of code in a large application has a lot of benefits, such as:-

  1. Simplicity,
  2. Flexibility,
  3. Reusability, and
  4. Scope.

A document with definitions of functions and various statements written in Python is called a Python module.

In Python, a module can be defined in three ways:-

  1. Python allows for creation of modules,
  2. A module can be written in the C programming language and dynamically inserted at run-time. The reason for this is because Python itself is written in C. When a program is written in Python, it is executed in a Python interpreter, which is written in C, such as re (regular expression).
  3. Python has several builtin modules that are included in the Python interpreter, such as itertools.

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet