Comparing numbers
Straightforward — the values are compared numerically. 9 < 100 is True.
Comparing strings and characters
Strings are compared character by character, using their character codes (3.3.5). This makes comparison effectively alphabetical, not numerical.
'apple' < 'banana' # True — 'a' has a lower code than 'b'
'cat' < 'cattle' # True — identical so far, but 'cat' is shorter
'Zebra' < 'apple' # True — uppercase codes are LOWER than lowercase
How the comparison actually works: compare the first characters. If they differ, that decides it. If they are the same, move to the second, and so on. If one string runs out first, the shorter one is "less".
The trap that breaks validation
Because comparison is by character code, numbers stored as strings compare wrongly:
'9' < '100' # FALSE! — '9' has a higher code than '1'
9 < 100 # True — compared as numbers
This is why an age or a score stored as a string cannot be range-checked correctly, and why keyboard input must be converted before it is compared numerically (3.2.1, 3.2.8).
Case sensitivity
'YES' = 'yes' # False — different character codes
Uppercase and lowercase letters have different character codes (in ASCII, 'A' is 65 but 'a' is 97), so they are different values. A login check comparing 'Admin' with 'admin' will fail. Real programs convert both to the same case before comparing.
Comparing Booleans
IF found = True THEN # works, but verbose
IF found THEN # better — the Boolean IS the condition
Both are correct, but the second is cleaner and is what experienced programmers write.
AQA tip. If a question involves comparing text that a user has typed, mentioning case sensitivity as a potential problem is a genuine, creditworthy observation in 'explain' and 'evaluate' answers.