Browse tools
Details and outline
Sets
6
Runs on
Python in your browser

Your code and progress stay on this device. Progress is kept in this browser's local storage.

Practice

Python Drills

Short function-writing exercises for a first course in Python. Write the function, press Run to try the examples, and press Submit to check it against hidden tests.

Open a set

Practice sets

How it works

Graded by running your code

Your function runs in a real Python interpreter in this browser tab, on a worker thread, so a loop that never ends is stopped after a few seconds instead of freezing the page. The page calls your function with example inputs and compares what comes back with the expected answer. Any correct solution passes, not only the reference one.

Some drills add rules about how the code is written, such as no loops in a recursion drill. Those are checked on the structure of your code. A failing test shows the call, what was expected and what your code produced.

You earn a star for a correct solution and a second for solving it without hints or a worked answer. The tests and reference answers ship with the page, so this is for practice, not assessment. For a free-form Python prompt, use the Scratchpad. The drills are companions to theLearning Python study notes.