Coding exercises
Plain Python, one challenge at a time
No game this time: a challenge to read, an editor for your code, and tests that tell you the moment it works. From your very first print to programs that read and write files.
The first five challenges are open to everyone: no account needed.
How a challenge works
- 1
Read it
What to make, an example of what it prints, and hints one at a time when you need them.
- 2
Write it
The editor helps as you type: what each command does, in your own language. Run it as often as you like.
- 3
Check it
Check runs the tests. Each one says what it expected and what it got, until every one passes.
Five levels, from the first print to the olympiad
Every challenge has a level, so a class in its first year of Python and a student before the exam each find their own. Pick a level and the list keeps only its challenges.
- 1First stepsOne idea at a time, explained with an example.21 challenges
- 2Two ideasTwo ideas together, still explained.38 challenges
- 3Small programsLoops, lists and functions: you plan it.34 challenges
- 4Exam levelData files and several steps, like the state exam.16 challenges
- 5OlympiadAn idea makes it quick, like an olympiad's first round.4 challenges
Step by step
The challenges come in groups, each a topic, each a little harder than the one before.
- 1Python basicsClassic challenges: printing, input, numbers, if, loops, text, functions and files.10
- 2Printing and variablesThe first steps: print text and numbers, keep values in variables, and put them together.8
- 3Input and arithmeticAsk for numbers, turn text into numbers, and calculate: whole parts, remainders and decimals.8
- 4ConditionsLet the program choose: if, elif and else, comparing numbers, and joining conditions with and / or.9
- 5LoopsDo it again: for and range, while, adding up as you go, counting, and loops inside loops.10
- 6TextWork with words: letters by their place, slices, upper and lower case, counting, splitting and joining.9
- 7ListsMany values under one name: read a line of numbers, add them up, find the largest, pick some out, sort them.9
- 8FunctionsName a piece of code and use it again: def, parameters, return, and functions that use each other.8
- 9Dictionaries and setsLook things up by a name: dictionaries for counting and grouping, sets for what's different.9
- 10FilesRead data from a file and write answers to another: lines, numbers in rows, a count first, CSV.8
- 11AlgorithmsThe classics, by hand: the smallest and largest, searching, sorting, binary search, primes, GCD and other bases.10
- 12Exam practiceWhole exam-style challenges: a data file in a set format, several steps, and the answer written exactly as asked.7
- 13OlympiadFirst rounds of the olympiads: an idea makes it quick. Windows, prefix sums, a stack, greedy choices and counting in one pass.8
Debug
Watch your code run
Debug runs your program one step at a time: the line it's on lights up, and every variable shows what it holds right then.
- Steps back and forth, or straight to a line
- Lists and dictionaries drawn as boxes
- Errors explained next to their line
Projects
Make something of your own
A project is Python with no tests and no rules: as many files as you like, input() and output, saved with your account. Start empty or from an idea.
Start a project- BlankJust main.py
- Text adventureRooms, and input() to walk between them
- CalculatorTwo numbers, and what to do with them
- GradesA CSV read, and a report written
Python guide
Look anything up
The Python guide explains every idea with an example and exactly what it prints, in five parts.
Python guideFor teachers
Write challenges of your own with their tests, give them to a class, follow each student's code in a live lesson, and play back how it grew.
Your first challenge takes a minute
Print one line, press Check, and see the tests go green.
Try the first challenge