Cambridge pseudocode

Not Equal To in Pseudocode

<> is a question, not an assignment. It is true when the two sides are different. IF Count <> 0 THEN reads “if count is not zero.” The opposite question is =.

How it works

One sign, and it is not the Python one

Cambridge has no != and no /=. Those are other languages, and this compiler rejects them. The editor can offer <> when it sees !=. The rest of the comparisons are <, >, <= and >=. Prefer <- for storing a value, so a lone = stays visibly a test.

DECLARE Count : INTEGER
Count <- 3
IF Count <> 0 THEN
    OUTPUT "Still counting"
ENDIF
Output
Still counting

In Python

The same test is !=

Python
count = 3
if count != 0:
    print("Still counting")

Beyond the exam

Where <> came from

<> is the not-equal of BASIC, Pascal and SQL. C wrote !=, and Python, Java and JavaScript followed C. The two signs mean the same comparison. They are not interchangeable inside one language: a Cambridge script with != is a syntax error, and a Python script with <> has been a syntax error since Python 3. When you move a program across, this is one of the characters you translate on purpose.

Run the example in the pseudocode compiler online, or read the matching section of the Cambridge pseudocode guide.