You don't have to define every procedure you use in a program. If you're using already-written code, you can import it into your program. In Python, you do this by importing the module it's contained in. This importing usually takes the form of a line of text at the top of your program that looks like this:
from location import module
There are several places where already-written modules come from.
A software library contains already-developed procedures that you can use in creating your own programs. You don't have to write new procedures to, for example, display images or find derivatives in your program; someone's already written those procedures and put them in a library for the public to use.
There are libraries for everything under the sun. Here are some Python examples:
- Pillow allows you to work with images.
- Matplotlib allows you to make 2D graphs and plots.
You can also
import some of your own previously written code into a new program.
An Application Program Interface, or API, contains specifications for how the procedures in a library behave and can be used. It allows the imported procedures from the library to interact with the rest of your code.
In order to make the most of both APIs and Libraries, both need to be well documented. Libraries are, at their heart, a collection of other people's code, and it would be difficult to understand how the procedures should be used without documentation. APIs explain how two separate pieces of software interact with each other, and they also need documentation to keep this communication going.