Loading…
Loading…
Loading…
AQA GCSE Computer Science · 8525
AQA 8525 Check the specification (PDF) (opens in a new tab)
A program often needs to decide whether something is the case: has a player reached a target score, are two answers the same, or is one value larger than another?
A relational operator compares two values. The result is a Boolean value: either True or False. For example, 4 < 6 evaluates to True, while 6 < 4 evaluates to False. The result is not a number showing the difference between the values; it tells us whether the comparison is true.
A comparison can use literal values, variables or expressions. If score currently holds 12, then score > 10 evaluates to True. If the value of score changes, the result of that comparison may change too.
AQA pseudo-code uses these symbols:
| Operator | Meaning | True example | False example |
|---|---|---|---|
= | Equal to | 3 = 3 | 3 = 4 |
≠ | Not equal to | 3 ≠ 4 | 3 ≠ 3 |
< | Less than | 3 < 4 | 4 < 4 |
> | Greater than | 4 > 3 | 4 > 4 |
≤ | Less than or equal to | 4 ≤ 4 | 5 ≤ 4 |
≥ | Greater than or equal to | 4 ≥ 4 | 3 ≥ 4 |
Read each comparison from left to right. score ≥ target means that the score is greater than or equal to the target.
The equality part matters at a boundary. Suppose a player qualifies with a score of at least 10. The condition is score ≥ 10: a score of exactly 10 qualifies. Using score > 10 would exclude that score. Similarly, “fewer than 10” means < 10, whereas “no more than 10” means ≤ 10.
A variable is a named storage location whose value can change. Assignment puts a value into that variable; comparison tests a relationship between values.
score ← 10
score = 10
The first line stores 10 in score. The second expression tests whether score equals 10 and evaluates to True. It does not change the value of score.
Different programming languages use different symbols for the same comparisons. For example:
| Meaning | AQA pseudo-code | Python 3 |
|---|---|---|
| Equal to | = | == |
| Not equal to | ≠ | != |
| Less than | < | < |
| Greater than | > | > |
| Less than or equal to | ≤ | <= |
| Greater than or equal to | ≥ | >= |
Thus, AQA’s score ≥ 10 and Python’s score >= 10 test the same relationship. To interpret an algorithm, recognise the operation’s meaning rather than relying only on how its symbol looks.
When a comparison contains arithmetic, calculate the arithmetic values first, then compare them. For example:
(3 * 4) ≤ 15 becomes 12 ≤ 15, so the result is True.(15 MOD 2) = 0 becomes 1 = 0, so the result is False.(50 - 40) > (3 * (2 + 5)) becomes 10 > 21, so the result is False.Brackets make the intended calculations easier to read.
Comparisons are not restricted to integers. Real numbers can be compared too: 4.1 > 4.0 is True, and 4.5 ≥ 4.5 is also True.
Characters and strings can have an order. For example, 'A' < 'B' is True. Strings can be compared in lexicographic order, like dictionary order. Compare their characters from left to right until a difference determines which comes first: 'adam' < 'adele' is True because their first two letters match, then a comes before e. Use values of appropriate, compatible data types rather than assuming that any two kinds of data can be meaningfully ordered.
A condition is an expression that evaluates to True or False. In selection, it determines whether a block of instructions runs.
Suppose a game awards a qualification message for reaching a target score:
score ← 10
targetScore ← 10
IF score ≥ targetScore THEN
OUTPUT 'Qualified'
ENDIF
Substituting the current values gives 10 ≥ 10, which is True, so the message is output. With a score of 9, the condition would be False and the output instruction would be skipped.
To construct a condition, identify the two values being compared, decide which relationship expresses the rule, and check what should happen when the values are equal.
In condition-controlled iteration, a comparison can determine whether instructions repeat. Its result must be checked using the latest variable values.
number ← 1
WHILE number < 4
OUTPUT number
number ← number + 1
ENDWHILE
The condition is initially 1 < 4, so the program outputs 1 and changes number to 2. It then checks the condition again.
Value of number when checked | Result of number < 4 | Action |
|---|---|---|
| 1 | True | Output 1; increase to 2 |
| 2 | True | Output 2; increase to 3 |
| 3 | True | Output 3; increase to 4 |
| 4 | False | Leave the loop |
The output is therefore 1, 2, 3. The final value of number is 4, but 4 is not output because the comparison becomes False before the output instruction runs again.
A REPEAT–UNTIL loop uses a stopping condition instead:
number ← 1
REPEAT
OUTPUT number
number ← number + 1
UNTIL number = 4
Here, the equality comparison is checked after the instructions. Once number becomes 4, number = 4 is True and repetition stops. This also outputs 1, 2, 3. The key distinction is that WHILE repeats while its condition is true, whereas UNTIL ends repetition when its condition is true.
| AQA symbol | Meaning |
|---|---|
= | Equal to |
≠ | Not equal to |
< | Less than |
> | Greater than |
≤ | Less than or equal to |
≥ | Greater than or equal to |
Every comparison returns True or False. < and > exclude equality; ≤ and ≥ include it.
≥; “at most” → ≤.← for assignment and = for equality.==, !=, <, >, <=, >=.IF: run the block if the condition is True.WHILE: check before each repetition; continue while True.REPEAT–UNTIL: check after each repetition; stop when True.Check the boundary value: < and > exclude equality, whereas ≤ and ≥ include it.
In AQA pseudo-code, ← assigns a value and = compares values. In Python, assignment uses = and equality comparison uses ==.
When tracing an algorithm, use each variable’s current value and evaluate arithmetic before making the comparison.
Read loop conditions carefully: WHILE continues when its condition is True; REPEAT–UNTIL stops when its condition becomes True.
When writing conditions, use meaningful identifiers and the comparison symbols appropriate to your programming language.
It can see this note and what your specification asks for.
Answers are free with an account.
1 free note left this week
Get more free notesYour answer sets when this note comes back for review, or marks it complete.
Was this note helpful?
Log in to tell us whether it helped, or to report a problem.
Last updated
Relational operator
An operator that compares two values and produces a Boolean result, either True or False.
Boolean
A data type with only two possible values: True and False.
Condition
An expression that evaluates to True or False and can control whether instructions run or repeat.
Assignment
An instruction that stores a value in a variable. AQA pseudo-code uses ← for assignment.
Lexicographic order
An ordering of strings like dictionary order, determined by comparing characters from left to right.
Put your knowledge into practice — try past paper questions for Computer Science
Relational operator
An operator that compares two values and produces a Boolean result, either True or False.
Boolean
A data type with only two possible values: True and False.
Condition
An expression that evaluates to True or False and can control whether instructions run or repeat.
Assignment
An instruction that stores a value in a variable. AQA pseudo-code uses ← for assignment.
Lexicographic order
An ordering of strings like dictionary order, determined by comparing characters from left to right.