Do not write what exists
You need to show today's date in your app. Do you work out leap years yourself? You could. It would take a week and have bugs.
Somebody already wrote it and tested it. You import it and use it in one line.
A good developer knows what to build and what to borrow.
Key words
| Word | What it means | Example |
|---|---|---|
| Module | A file of ready-made code that you can import. | json |
| Package | A folder of modules, shared so others can install it. | |
| Library | A collection of code that gives you extra features. | |
| Standard library | The libraries that come with the language, with nothing to install. | |
| Dependency | A library your program needs to work. | |
| Package manager | A tool that downloads and updates packages. | pip, npm |
| API | A set of ready-made jobs or web addresses that another program offers for you to use. | |
| Version | A number that says which release of a library you have. | 2.31.0 |
| Licence | The rules that say how you may use a piece of software. |
The cells students fill in are left blank in this preview.
Try it: import a module
import json
from datetime import date
text = '{"name": "Sam", "goals": 3}'
data = json.loads(text) # text to a dictionary
print(data["name"])
today = date(2026, 11, 1)
print(today.strftime("%d %B %Y"))
print(today.weekday()) # 0 is Monday
# Change the date and run again.
Where does code come from?
There are three places.
The standard library comes with the language. It is safe and always there. json, datetime and random are in it.
A package from a package manager is written by other people. You install it with pip for Python or npm for JavaScript.
An API lets you use a service on another computer, such as a weather forecast.
Quick check
Have a go
Quick check
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Try it: count with a library
from collections import Counter
import random
words = "goal goal miss goal miss save".split()
print(Counter(words))
print(Counter(words).most_common(1))
rng = random.Random(5) # a seed: the same numbers every time
print(rng.choice(["Aisha", "Ben", "Sam"]))
print(rng.randint(1, 6))
# Run it twice. Why do you get the same result?
Choose a library with care
| Ask | Why it matters |
|---|---|
| What is the licence? | It may forbid your use, or force you to share your code |
| Is it still looked after? | A library with no updates for years may have unfixed bugs |
| How big is it? | A big library slows your app and your downloads |
| Is it secure? | Check for known problems before you add it |
| Does it have good documentation? | You must be able to learn it without asking anybody |
| Does it work on our platform? | Compatibility: it must work on your system, such as Windows or Linux, and with your language version |
The cells students fill in are left blank in this preview.
Pin the version
data-callouts.important.label
A new version can change how a library works. Write the version you tested in a list file, for example: requests==2.31.0. Then your product works the same on every computer.
What libraries can add
Libraries add features that would take you weeks to write. Some play audio or resize pictures: this is media content. Some give buttons, menus and charts: these are interface components. Others help one program work on many systems: this is compatibility.
Always read the documentation first. It shows examples and warns about problems.