LEARNING 2 minute read
One concept. One experiment.
A simple routine for turning a short explanation into something you can use yourself.
By Mbiopeter
Predict before you run
Read a short program and write down the output you expect. Choose one input that makes its behaviour easy to follow. If the actual result differs, look for the first step where your prediction and the program disagree.
values = [2, 4, 6]
total = 0
for value in values:
total += value
print(total)Try the boundary
Once the ordinary case makes sense, change one thing. Try zero, a negative number, a repeated value or an empty input when the exercise allows it. Follow the stated input format: a useful test should check the problem the program is meant to solve.
- Predict the result.
- Run one small example.
- Explain any difference.
- Try a relevant edge case.
- Write the idea again without looking at the solution.
Keep the next step small
The Playground keeps a separate draft for each language and challenge. Hints can help when you are stuck, and saved answers distinguish guided attempts. Start with adding two numbers, then move to a new exercise when you can explain your solution.