Revision Notes
OxfordAQA IGCSE Computer Science (9210): Boolean operations in a programming language – Revision Notes
Revision notes for OxfordAQA IGCSE Computer Science 9210 section 3.2.5: NOT, AND and OR, compound conditions, range checks, evaluation order and a self-test.
- Subject
- Computer Science
- Level
- IGCSE
- Topic
- Topic 2 – Programming
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to OxfordAQA IGCSE Computer Science (9210), For teaching from September 2017, exams from May/June 2019. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA IGCSE Computer Science.
Syllabus points this page covers
9210
- 3.2.5 Boolean operations in a programming language
Found an error? Report a correction.
Need help with this topic? Request a free trial class for IGCSE Computer Science (9210).
Condensed notes for section 3.2.5 Boolean operations in a programming language of OxfordAQA International GCSE Computer Science (9210). Worked examples are in the Boolean operations study guide.
What the specification asks
- Be familiar with and use NOT, AND, OR.
- Use these operators, and combinations of them, within conditions for iterative and selection structures.
Truth table
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| F | F | F | F | T |
| F | T | F | T | T |
| T | F | F | T | F |
| T | T | T | T | F |
- AND: all parts True.
- OR: at least one part True (both counts).
- NOT: reverses one value.
Patterns worth memorising
| Purpose | Condition |
|---|---|
| Inside a range (inclusive) | x ≥ low AND x ≤ high |
| Outside a range | x < low OR x > high |
| Accept either of two answers | reply = "Y" OR reply = "y" |
| Keep looping while both hold | WHILE lives > 0 AND NOT won |
| Search until found or end reached | WHILE NOT found AND i < size |
| Test a Boolean is False | NOT found (no need for = False) |
| Login succeeds | user = storedUser AND pass = storedPass |
Order of evaluation
NOT first, then AND, then OR (in most languages). a OR b AND c = a OR (b AND c).
Use brackets whenever AND and OR are mixed.
Example with a = True, b = False, c = False:
a OR b AND c→True OR False→ True(a OR b) AND c→True AND False→ False
Loops with compound conditions
WHILE p AND qstops as soon as eitherporqbecomes False.WHILE p OR qkeeps going until both are False.- Converting to
REPEAT...UNTIL:UNTIL NOT (p AND q)stops at the same point (the body still runs at least once).
Evaluating step by step
For IF score ≥ 50 AND (bonus OR level > 3) with score = 60, bonus = False, level = 2:
score ≥ 50→ Truebonus OR level > 3→False OR False→ FalseTrue AND False→ False
Mini trace: a loop with two exit conditions
total ← 0
count ← 0
WHILE total ≤ 20 AND count < 4
total ← total + 7
count ← count + 1
ENDWHILE
| Pass | total | count | total ≤ 20 |
count < 4 |
Continue? |
|---|---|---|---|---|---|
| start | 0 | 0 | True | True | Yes |
| 1 | 7 | 1 | True | True | Yes |
| 2 | 14 | 2 | True | True | Yes |
| 3 | 21 | 3 | False | True | No |
The loop stops after three passes because the first part became False, even though count < 4 was still True.
Key terms
| Term | Meaning |
|---|---|
| Boolean operator | An operator (NOT, AND, OR) that works on True/False values |
| Compound condition | A condition made from two or more comparisons joined by Boolean operators |
| AND | True only if both operands are True |
| OR | True if at least one operand is True |
| NOT | Gives the opposite of its operand |
| Truth table | A table listing the output for every combination of inputs |
Exam traps
- Half-written comparisons:
age > 12 AND < 18must beage > 12 AND age < 18. x = "A" OR "B"must bex = "A" OR x = "B".- “Never true” conditions:
x < 0 AND x > 100can never be True; outside a range usesOR. - “Always true” conditions:
x ≠ "A" OR x ≠ "B"is True for every value ofx; to reject both, useAND. - English “and” meaning “either”: “children and over-65s travel free” needs
OR. - No brackets when mixing
ANDandOR. - OR treated as exclusive: True OR True is True.
Self-test
- State the value of
True AND False. - State the value of
NOT (5 > 3). - State the value of
(4 = 4) OR (2 > 9). - Write a condition that is true when
speedis from 30 to 50 inclusive. - Write a condition that is true when
speedis outside the range 30 to 50. - Correct the condition
IF colour = "red" OR "blue" THEN. - A loop is
WHILE tries < 3 AND NOT correct. Give the two situations that end it. - With
a = False,b = True,c = True, evaluatea AND b OR c. - Evaluate
a AND (b OR c)with the same values. - Explain why
IF n ≠ 0 OR n ≠ 1 THENis always true. - Write a condition for “free entry for under-5s and over-80s”.
- Write the
UNTILcondition equivalent toWHILE NOT finished AND count < 10.
Answers:
- False.
- False.
- True.
speed ≥ 30 AND speed ≤ 50.speed < 30 OR speed > 50.IF colour = "red" OR colour = "blue" THEN.triesreaches 3, orcorrectbecomes True.- True (
a AND bis False;False OR Trueis True). - False (
b OR cis True;False AND Trueis False). - Any value of
nis different from at least one of 0 and 1, so at least one side is always True. age < 5 OR age > 80.UNTIL NOT (NOT finished AND count < 10), or equivalentlyUNTIL finished OR count ≥ 10.
More resources on this topic
Related resources
-
Study guides
OxfordAQA IGCSE Computer Science (9210): Classification of programming languages and translators
Study guide to OxfordAQA IGCSE Computer Science 9210 section 3.2.13: machine code, assembly, high-level languages, compilers, interpreters and assemblers.
Computer Science · OxfordAQA · IGCSE
Read guide -
Practice questions
OxfordAQA IGCSE Computer Science (9210): Classification of programming languages and translators – Practice Questions
Original OxfordAQA IGCSE Computer Science 9210 practice questions with answers on machine code, assembly, high-level languages and the three translators.
Computer Science · OxfordAQA · IGCSE
Try questions -
Revision notes
OxfordAQA IGCSE Computer Science (9210): Classification of programming languages and translators – Revision Notes
Revision notes for OxfordAQA IGCSE Computer Science 9210 section 3.2.13: low- and high-level languages, the three translators, exam traps and a self-test.
Computer Science · OxfordAQA · IGCSE
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.