This page holds a tiny Python-like interpreter and five short exercises. You run the code, the tool compares the output with the expected output, and if the test fails it gives questions to think about.
It is for building the habit of reasoning about code, not just running it.
How do you use it?
- Pick an exercise. Read the one-line brief, for example “The program should print 15.”
- Predict the output before you touch the button. Write down what you think will appear.
- Press Run and test. Reset returns the first exercise.
- Read the result. If it passed, try to explain why. If it failed, use the “Think about it” questions, fix the code in the text box and run again.
Indent with spaces. The supported subset is listed under the code box: + - * / // % **, comparisons, and/or/not, print(), int(), str(), abs(), len(), min(), max(), if/elif/else, while, for … in range(…), break and continue.
How do you read the result?
You see your output on the left and the expected output on the right, with a message saying whether they match. Below that are the number of steps executed and the variables as they stood at the end.
If the safety limit stopped the code, a warning appears above the comparison. A stopped program still shows what it printed before the limit, which is often enough to spot the pattern.
Example walk-through
Open Sum of 1 to 5 (has a bug). The code adds n from range(1, 5) into total and prints it. The expected output is 15.
Run it. The output is 10 and the test fails. Read the first prompt: which numbers does range(1, 5) produce?
It gives 1, 2, 3, 4, because the stop value is not included. So total is 1 + 2 + 3 + 4 = 10, not 15.
Change the stop value to 6 and run again. The numbers are 1 to 5, the total is 15 and the test passes.
Next open Doubling until over 50. Start at x = 1 and double while x <= 50. The values go 2, 4, 8, 16, 32, 64.
At 64 the condition is false, so the loop ends and 64 prints. The condition checks the value before doubling, which is why the final value overshoots 50.
Then try Faulty loop: while True. It prints 0 forever, so the tool stops it at the limit. The brief asks you to make it print 0, 1, 2. Change the loop so n increases each pass and stops when n reaches 3, then run it.
What are the assumptions and limits?
- It is a subset of Python. Division with / prints whole-number results without “.0”.
- There are no user-defined functions, lists, string methods or imports.
- Programs are capped at 60 lines and output is capped at 200 lines.
- Runaway loops stop at 5000 steps or 300 ms.
- It cannot see or change any file, and it makes no network request.
- It is original practice only. It is not an exam environment and does not mark assessed work.
Which lessons explain the result?
For loops, read repair an off-by-one error, which explains exactly the range(1, 5) mistake above. The habit of predicting is taught in explain an expected result before running code, and identify an untested branch shows what passing one test does not prove.
To follow values through a function, see trace a returned value. The whole route is in Python transition and execution.
If you would like a teacher to go through your loops and tests with you, see online one-to-one Computer Science tuition. The pseudocode trace trainer is a good partner, and more tools are in the learning tools directory.