The TopMarks Code Lab starts with the first line of Python. You do not need to install an editor or create an account. Twelve short lessons introduce the main ideas, and three projects help you use them together: a cost calculator, a mini choice adventure and a three-question quiz show.
Start with one variable
A variable is a name that refers to a value. Assignment stores the result of the expression on the right under the name on the left. Reading the name later uses its current value.
score = 4
score = score + 3
print(score)Before running this program, predict its output. Trace the first assignment, then calculate the right-hand side of the second assignment using the current value.
Reveal the answer and trace
The output is 7. The first line gives score the value 4. The next line calculates 4 + 3 and stores 7 under the same name. The final line reads that updated value. In assignment, = stores a value; == is a comparison used to ask whether two values are equal.
Your beginner learning path
Begin with instructions and one variable, then change a value and combine several variables. Next, distinguish numbers from text and read input. Practise comparisons and decisions before learning counted and condition-controlled loops. Lists keep several values together; functions let you reuse a small piece of work.
The lessons are open in order, but you can revisit any one when you need it. Most short lessons are designed for about 10–15 minutes; projects allow more time for testing and explaining.
Three projects with a purpose
- Cost calculator: read a whole-number price and quantity, multiply them and display a labelled total. Test different inputs and zero quantity.
- Mini choice adventure: combine two decisions to produce different story routes. Test every combination rather than only your favourite path.
- Quiz show: combine a list, repetition, a score and a reusable checking function. Explain why a wrong response should not increase the score.
Learn, predict, explore, build, check, apply
Each lesson breaks the work into small stages. Predict before you run. In Explore, inspect the worked example and its replay. In Build, type or use guided code lines. Run checks to compare expected and actual results, then use Apply to attempt a fresh task.
Help comes in steps: a nudge, a clearer clue and a worked answer. Reveal only what you need, then explain the change in your own words. A passing check records evidence for that draft; changing the program means it needs checking again.
When a program does not work
- Read the first error or first failed case.
- Write down what you expected and what happened.
- Make one small change that addresses that difference.
- Run the relevant checks again, including a different input.
Keep your draft while you use the clues. Download the Python file or your saved work if you want a copy outside this browser.
What the browser lab supports
The lab runs a constrained Python 3 subset locally and accepts supplied input lines. It is designed for learning these exercises, not for installing packages, accessing files or networking. Progress stays in your browser and does not sync to an account. Completing practice is not an exam grade.
When these ideas feel familiar, open the GCSE Python practice guide. For wider Python language examples, consult the official Python introduction.
You can print this guide from your browser for lesson planning or independent study.
Start the beginner Code Lab →