Python for Transport & Civil Engineering¶
Five weeks. You start by running someone else's script. You finish by building a transport atlas of a place you choose, using national open data and an AI assistant.
Keep this page open beside your editor. It has the same text as the files in the repository, so you can read a task on one side of the screen and do it on the other.
Two things before you start
Nothing here is graded. No submissions, no presentations, nobody reviewing your work. Nothing is collected at any point.
The answers are published. Worked solutions to weeks 1 and 2 are in
instructor/solutions/. Use them to check your work after you have
tried a task.
Before week 1¶
Apply for GitHub Education on day one
GitHub gives verified students GitHub Copilot for free and 180 Codespaces hours a month instead of 120. Both are used in this course.
Verification is not instant. It can take a few days. Apply in week 1, not in week 4.
Then set up your machine. This takes about 45 minutes.
-
Windows
Tick "Add python.exe to PATH" on the first installer screen.
-
macOS
Do not use the Python that came with your Mac.
-
No installation
A Codespace runs in your browser. Nothing to install.
-
Restricted laptop
No admin rights, or a network that blocks downloads.
Then, in the course folder:
Read what it prints. If it reports a problem, it also names the fix.
If something does not work¶
Try these in order.
- Read the message to the end. It usually names the problem.
- Read the "If this fails" notes in your setup guide. Common problems are listed there with their fixes.
- Paste the exact error into an AI assistant. Ask what it means. Installation errors are well documented.
- Search for the exact error text.
- After 30 minutes, stop. Use Codespaces. It needs no installation. You lose nothing from the course.
- Still stuck at the session? Bring it. The instructor and TA are there.
The five weeks¶
Weeks 1 to 3 teach you to read code, write it, and check whether it is right. Weeks 4 and 5 are one project, mostly about finding data and knowing what is wrong with it.
-
Week 1 — Getting Python working
What a program is, where files live, how to read an error message. Then two tasks: a parameter sweep and six broken scripts.
-
Week 2 — Actually programming
Variables, types,
if, loops, functions, NumPy, and your first figure. Then twelve drills. -
Week 3 — AI acceleration
Your job becomes describing the work and checking the result. Built around a demonstration of an assistant being wrong.
-
Weeks 4 and 5 — Your Patch
Seven chapters of national data about a British town you choose.
-
A worked example
The same project, built for Leeds by an AI assistant. Its plan, its figures, and the four things it got wrong.
Three rules¶
- A figure with an unlabelled axis is not finished. Label both axes. Give units. Write a title a stranger can understand.
- Code you cannot explain is not finished. From week 3 you check whether your answers are right.
- Getting stuck is normal. Read the error message first.