Skip to content
2210 / 0478 Paper 2 · 9618 Paper 4

ZAK's Python Playground

Real Python 3 running inside your browser — nothing installed, nothing sent to a server. Write the program, give input() its values, press Run and get the output, any files it wrote and a line-by-line trace table. Every pseudocode guide construct has its Python twin in the Examples; switch the toggle to Pseudocode to compare.

Loading playground…

Python example library

49 programs — the same categories as the pseudocode library, written the way Paper 2 / Paper 4 expect them.

  • Basics & data types 5

    Variables, constants, INPUT/OUTPUT, arithmetic, DIV/MOD, conversions

  • Selection 3

    IF/ELSE, nested IF, CASE with lists and ranges, Boolean conditions

  • Iteration 4

    FOR, WHILE, REPEAT, nested loops, totalling, counting, max/min

  • String handling 4

    LENGTH, SUBSTRING/MID, UCASE/LCASE, ASC/CHR, reversing, palindromes, ciphers

  • Arrays 3

    1D and 2D arrays, parallel arrays, whole-array copy, frequency counts

  • Procedures & functions 3

    Parameters, RETURN, BYREF vs BYVAL, scope, stepwise refinement

  • Validation, testing & exceptions 3

    Range, length, type, format and check-digit checks; verification; test data; trace tables; TRY … EXCEPT

  • Searching 2

    Linear search, binary search (iterative and recursive), comparing efficiency

  • Sorting 2

    Bubble sort (with and without a flag), insertion sort, sorting strings and parallel arrays

  • File handling 3

    Text files (READ/WRITE/APPEND, EOF), delimited records, random-access files

  • Records & user-defined types 2

    TYPE…ENDTYPE records, arrays of records, enumerated, pointer and set types, DATE

  • Stacks, queues, lists & trees 5

    Stack, linear and circular queue, linked list, binary search tree, hash table, dictionary

  • Recursion 2

    Base and general cases, winding/unwinding, factorial, Fibonacci, GCD, Hanoi

  • Object-oriented programming 3

    Classes, constructors, encapsulation, inheritance, polymorphism, containment

  • Theory in code 3

    Number bases, two's complement, parity, logic gates, adders, FDE cycle, compression, floating point, RPN, graphs

  • Exam-style tasks 2

    Complete scenario programs in the style of 2210 Section B, 9618 Paper 2 and Paper 4

How the Python Playground works
  • It is real CPython 3 (Pyodide, compiled to WebAssembly). The whole standard library is there: math, random, csv, json, datetime, dataclasses, enum, re… Third-party packages (numpy, pygame) are not.
  • input() reads the next line of the INPUT box; the prompt and value are echoed as they would be in a terminal. If the program asks for more than you gave, you get an “INPUT needed” error, like the pseudocode Playground.
  • Files are written to a scratch folder that is emptied before each run; whatever the program writes is shown under the output.
  • Errors show the line, the exception and a hint an examiner would give (a str + int TypeError, an off-by-one IndexError, a missing colon…).
  • Trace table records every change to a variable, line by line — including inside functions — so you can check your own trace of a loop or a recursive call.
  • Infinite loops are stopped after 250 000 lines or 12 seconds; Python then restarts automatically.
  • First use downloads about 7 MB (cached afterwards). On a slow connection the Run button waits until Python is ready.
Enroll nowOnline classes