πŸ”„ WJEC Pseudocode ↔ Python

Plan a routine, compare its Python implementation and test it. For Made-for-Wales GCSE Computer Science, teaching from 2025.

CS GCSE (2025) Β§1.4.1; Unit 2, 2.1–2.4 (selected skills)CS AS Units 1 and 2 (support only)

Start here

Choose an example. Predict its output, then use either conversion button. Edit the design, convert it to Python and test it in IDLE. Pseudocode explains the algorithm; Python implements it. Go to the editors.

The core notation follows Appendix B, Notes 2–3, with input and loop examples from the Unit 1 teaching guidance. This is an independent practice tool, not an official marking or execution system.

Converter

Both editors are editable. Converting replaces the other editor. Code stays in this browser and is not run or uploaded. Use spaces for Python indentation.

Predict, trace, test, refine

Suggested tests for this example. These are predictions, not results from running your edited code.
Test kindData / setupExpected result or issue to investigate

In OneNote, add columns for actual result, pass/fail and refinement with a reason. Run the tests in IDLE, record evidence and explain any differences.

How this supports Unit 2

  • 2.1 Investigation: identify inputs, outputs, constraints and success criteria; split the problem into routines before converting.
  • 2.2 Design: document data and interfaces; write pseudocode for validation, verification, authentication and processing. A Python listing does not replace the design.
  • 2.3 Implementation: develop and annotate Python functions, control flow, strings, data structures and files. Extend routines and build the real interface in IDLE.
  • 2.4 Testing, refinement and evaluation: predict typical, extreme and erroneous tests, compare outcomes and justify improvements.
Tkinter and the wider practical work

The converter handles callback logic, not Tkinter widget declarations. The following original example connects the β€œGUI callback logic” routine to an Entry, Button and Label. Design the interface first, then combine this with check_name in IDLE.

import tkinter as tk

window = tk.Tk()
window.title("Presence check")
name_entry = tk.Entry(window)
name_entry.pack()
feedback = tk.Label(window, text="")
feedback.pack()

def on_check():
    message = check_name(name_entry.get())
    feedback.config(text=message)

tk.Button(window, text="Check", command=on_check).pack()
window.mainloop()

Interface design: when the button is pressed, read the entry, call the checking routine and display its returned message. In IDLE, test keyboard focus and empty text, and annotate the callback.

Also practise modules, frames, widgets and geometry managers; fixed-length records; wider validation techniques; debugging and changes to supplied code. Use the Python 3/IDLE version specified by the pre-release and examination instructions. These examples are not the live assessment scenario and do not cover all Unit 2 requirements.

Notation reference

Keywords are shown in the WJEC style. The converter accepts mixed-case pseudocode keywords. Variable names remain case-sensitive, as in Python.

Core conventions and supported forms
PurposePythonWJEC-style pseudocode
Declare a typeTypes belong to valuesmark is integer
Assignmentmark = 12set mark = 12
Output / inputname = input("Name: ")name is string
output "Name: "
input name
Selectionif mark == 12:
print(mark)
if mark = 12 then
output mark
end if
Counted loopfor i in range(1, 6):
print(i)
for i = 1 to 5
output i
next i
Conditional loopwhile count > 0:
count = count - 1
while count > 0
set count = count - 1
repeat
Subroutinedef greet():
print("Hello")
greet()
Declare greet()
output "Hello"
End Subroutine
call greet()
Equality / inequality== / !== / <>
Logic and valuesand / or / not
True / False
AND / OR / NOT / XOR
TRUE / FALSE
Whole-number division / remainder// / %DIV / MOD
Indexed itemmarks[0]marks[0]
Length / trimlen(name) / name.strip()len(name) / trim(name)
Substringname[0:3]mid(name, 1, 3)
Comment# Explain why/** Explain why */

Loop bounds: WJEC to includes the final value; Python range excludes its stop. The converter adjusts this in both directions, including constant negative steps. It also accepts end while, as used in the teaching guidance, and repeat ... until. An until loop stops when its condition becomes true.

Types and positions: declare a type before pseudocode input. Python declarations become comments; integer/real input uses int/float. Ordinary list indices and classroom slices start at zero. mid starts at one, as illustrated in the sample assessment. Use non-negative substring lengths and valid positions. instring(start, text, search) also uses one-based positions and returns zero when absent. A character is a one-character Python string; add a length check.

Classroom notation and conversion limits

Appendix B is a set of conventions, not a complete executable language. We explicitly extend it for parameters and returned values, container literals, for each, explicit loop steps and the following operations. These are teaching choices, not extra official WJEC keywords.

  • text(value) converts to a string; digits_only(text) matches Python isdigit(); ascii_only(text) matches isascii(). Together they check for ordinary digits 0–9, not all valid Python integers. upper, lower, contains and find_index describe common operations.
  • slice(sequence, start, stop[, step]) uses Python's zero-based, stop-exclusive bounds. It is deliberately distinguished from mid. List, tuple and dictionary literals describe initial contents, rather than a WJEC array-size declaration.
  • open source from "data.txt" for reading, read_line(source), read_lines(source), call write_text(destination, text), call write_lines(destination, lines) and close source preserve file handles and newline characters. Writing mode overwrites a file; appending mode adds to it.
  • val here converts a valid number string to a real number. It is not Visual Basic's prefix-parsing function. Numeric conversion still needs suitable validation. Prompts are represented by separate output and input instructions.

Supported: short single-line expressions, nested selections/loops, named subroutines, returns, basic string/list/dictionary operations and text files. Not supported: imports, classes, Tkinter declarations, exceptions, comprehensions, f-strings, multiline expressions, arbitrary methods or automatic array allocation. Unsupported input clears the destination and explains the first problem. A rejection means the tool cannot translate it; the code or pseudocode may still be valid.

This tool does not run code or check every syntax, type or logic error. It is not a mark scheme or a full translator. Trace conditions, types, bounds and data handling, and test in IDLE. For negative operands, Python's floor division/remainder rules are retained; use non-negative operands for introductory DIV/MOD examples.