Browse tools

The Lantern Festival: Python Drills

Python DrillsSet A: The Lantern Festival

0 of 18 stars

Introduction

The Lantern Festival

The neighbourhood lantern festival is a week away and the organisers have a pile of small jobs that all turn out to be programs: tidy up programme codes, rank the lantern contest, count digits on ticket numbers, unpack gift boxes, pack supply crates and tally the stalls.

Each drill gives you a function to write. Run checks your code against the examples in the task. Submit checks it against the examples and a set of hidden tests, and tells you which one broke.

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.