Browse tools

The Toy Railway: Python Drills

Python DrillsSet F: The Toy Railway

0 of 12 stars

Introduction

The Toy Railway

The model railway club runs a layout in a church hall every month. Members keep a timetable, shunt carriages in and out of a siding and log every run in a text file.

Each drill gives you a function or class to write. Run checks your code against the examples. Submit adds hidden tests.

Python runs in this browser through Pyodide. Nothing you type is sent anywhere. The reference answers ship with the page, so this is for practice, not assessment.

How it works

  • Each drill asks for one function, or one class. Write it in the editor. The starter code names it for you.
  • Run calls your code on the examples shown in the task and lists what each call returned.
  • Submit also runs hidden tests and a few checks on how the code is written, such as no loops in a recursion drill.
  • Stars: one for a correct answer, and a second for solving it without hints or a worked answer.
  • Python runs in this browser. Your code and progress stay on this device. A runaway loop is stopped after ten seconds.

Want to explore without a checker? Open the Scratchpad, which has a Python shell on the same runtime.