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 that others can install. | |
| Library | Code that gives you extra features. | |
| Standard library | The libraries that come with the language. | |
| Dependency | A library your program needs to work. | |
| Package manager | A tool that downloads and updates packages. | pip, npm |
| API | Ready-made jobs or web addresses another program offers you. | |
| Version | The release number of a library. | 2.31.0 |
| Licence | The rules for using a piece of software. |
The cells students fill in are left blank in this preview.
Import a module and use it
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.
Make a free account to save your work and track your progress.
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.
Check: where code comes from
Have a go
Check: where code comes from
3 questionsCount words 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?
Make a free account to save your work and track your progress.
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
Important
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.
Check: what libraries add
Have a go
Check: what libraries add
3 questionsMatch the word
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Use four standard library modules
Use four standard library modules. Counter counts words. json reads data. datetime works out days. random picks a winner, and a seed makes it repeat. Read the comments. Press Run Tests.
import json
import random
from collections import Counter
from datetime import date
def count_words(text):
# Count each word, ignoring upper and lower case. Words are split by spaces.
# Give back a dictionary, like {"the": 2, "cat": 1}. Use collections.Counter.
return None
def order_total(json_text):
# json_text is like: {"items": [{"name": "tea", "price": 150}, {"name": "milk", "price": 90}]}
# Give back the sum of the prices (pence). Use json.loads.
return None
def days_until(today_text, due_text):
# Both are dates written like 2026-11-05. Give back the number of days from
# today to the due date. Use datetime.date.fromisoformat.
return None
def pick_winner(names, seed):
# Pick one name. With the same seed the same name must come back every time.
# Use random.Random(seed).
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Choose between two chart libraries
Your team needs a library to draw charts in a Python app. You find two. Library A is free, last updated four years ago, with one page of notes. Library B is free, updated last month, with clear guides and examples, but it is large. Choose one. Use at least four of the questions from the table: licence, looked after, size, security, documentation, platform. Then say how you would pin its version.
A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Exit quiz
Have a go