Skip to content

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.

Apply: https://github.com/education — what to prepare

Then set up your machine. This takes about 45 minutes.

  • Windows


    Tick "Add python.exe to PATH" on the first installer screen.

    Setup guide

  • macOS


    Do not use the Python that came with your Mac.

    Setup guide

  • No installation


    A Codespace runs in your browser. Nothing to install.

    Codespaces guide

  • Restricted laptop


    No admin rights, or a network that blocks downloads.

    Options in order

Then, in the course folder:

python check_setup.py

Read what it prints. If it reports a problem, it also names the fix.

If something does not work

Try these in order.

  1. Read the message to the end. It usually names the problem.
  2. Read the "If this fails" notes in your setup guide. Common problems are listed there with their fixes.
  3. Paste the exact error into an AI assistant. Ask what it means. Installation errors are well documented.
  4. Search for the exact error text.
  5. After 30 minutes, stop. Use Codespaces. It needs no installation. You lose nothing from the course.
  6. 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 1

  • Week 2 — Actually programming


    Variables, types, if, loops, functions, NumPy, and your first figure. Then twelve drills.

    Week 2

  • Week 3 — AI acceleration


    Your job becomes describing the work and checking the result. Built around a demonstration of an assistant being wrong.

    Week 3

  • Weeks 4 and 5 — Your Patch


    Seven chapters of national data about a British town you choose.

    The project

  • A worked example


    The same project, built for Leeds by an AI assistant. Its plan, its figures, and the four things it got wrong.

    The worked atlas

Three rules

  1. A figure with an unlabelled axis is not finished. Label both axes. Give units. Write a title a stranger can understand.
  2. Code you cannot explain is not finished. From week 3 you check whether your answers are right.
  3. Getting stuck is normal. Read the error message first.