Cambridge pseudocode
How to Declare a Constant in Pseudocode
CONSTANT binds a name to a value for the rest of the program. CONSTANT Passing <- 50. Every later line may read Passing. No line may assign to it, including a line inside a procedure.
How it works
The name is locked after the first binding
DECLARE creates a variable: a slot you can overwrite. CONSTANT creates a name for a value the task has promised will not change, a pass mark, a rate, a size. The lock is checked when the program runs. Passing <- 40 later is an error, not a quiet second value.
CONSTANT Passing <- 50
DECLARE Mark : INTEGER
Mark <- 64
IF Mark >= Passing THEN
OUTPUT "Pass"
ENDIFPass
In Python
Capitals are a promise, not a lock
Python will not stop you. PASSING = 50 and then PASSING = 40 is a legal program. The capital letters are a convention other programmers recognise, which is weaker than a language rule. A tuple or a frozen object can hold a value you do not mean to edit, but that is a different tool.
PASSING = 50
mark = 64
if mark >= PASSING:
print("Pass")
PASSING = 40 # allowed. Python has no CONSTANT.Beyond the exam
What the lock is for
A constant gives the reader a name instead of a bare 50, and it gives the language permission to assume the value never moves. In a compiled language that assumption can become a literal baked into the instructions. In an exam it is simpler than that: if the pass mark changes, it changes on one line, and a mistaken assignment is a mistake the interpreter will say out loud.
Run the example in the pseudocode compiler online, or read the matching section of the Cambridge pseudocode guide.