General style
Font style and size
Pseudocode is presented in Courier New. The size of the font will be consistent throughout.
Indentation
Lines are indented by four spaces to indicate that they are contained within a statement in a previous line. Where it is not possible to fit a statement on one line any continuation lines are indented by two spaces from the margin. In cases where line numbering is used, this indentation may be omitted. Every effort will be made to make sure that code statements are not longer than a line of code, unless this is necessary.
Note that the THEN and ELSE clauses of an IF statement are indented by only two spaces. Cases in CASE statements are also indented by only two spaces.
Case
Keywords are in upper case, e.g. IF, REPEAT, PROCEDURE. Identifiers are in mixed case with upper case letters indicating the beginning of new words, e.g. NumberOfPlayers.
Meta-variables : symbols in the pseudocode that should be substituted by other symbols are enclosed in angled brackets < >.
Example – Meta-variables
REPEAT
<Statements>
UNTIL <Condition>Lines and line numbering
Each line representing a statement is numbered. However, when a statement runs over one line of text, the continuation lines are not numbered.
Comments
Comments are preceded by two forward slashes //. The comment continues until the end of the line. For multi-line comments, each line is preceded by //. Normally the comment is on a separate line before, and at the same level of indentation as, the code it refers to. Occasionally, however, a short comment that refers to a single line may be at the end of the line to which it refers.
Example – comments
// This procedure swaps
// values of X and Y
PROCEDURE SWAP(X : INTEGER, Y : INTEGER)
Temp ← X // temporarily store X
X ← Y
Y ← Temp
ENDPROCEDURESingle-line comments in Python begin with #, for example:
# This is a comment
print('Hello, World!') # Comment after code
# print('Nothing to do')