A module is a manageable piece of a larger program that handles a particular task. Think of it as a black box: to use it, you need to know what input it takes, what job it does, and what output it gives back—not every detail of how it works. section 20.2
When dividing a program into modules:
- Give each module a specific task so you can write and test it separately. section 20.2
- Pass information between tasks through inputs and outputs rather than relying on what another task creates for itself. section 20.3
- Aim to write a module once and reuse it with different inputs. section 20.4
A group project
Imagine assigning two people separate research tasks. You need their findings for the final presentation, but you do not need to direct every step of their research. Each person works independently and shares a result—much like a module completing a subtask. section 20.3
In Python, a module can also mean a file containing definitions. If shapes.py defines Circle and Rectangle, another file in the same folder can use `import shapes` to bring in those definitions. Libraries group one or more modules. section 35.1
Figure 35.1. Two files: shapes.py and test.py in the same folder. One file defines classes for Circle and Rectangle. Another file imports the classes defined in shapes.py and uses them by creating different objects of those types and changing their data attributes.
See how one file defines classes while another imports and uses them. section 35.1


































