Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Combining AND, OR and NOT with brackets worksheet is part of the IGCSE Computer Science 0478 — 8.1b Sequence, Selection and Iteration journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1A OR B AND C | ANOT A AND B | |
| 2(A OR B) AND C | BMeans A OR (B AND C), because AND is worked out before OR when there are no brackets | |
| 3Brackets make NOT apply to a whole condition, so it is true only when both A and B are false | CA OR B is worked out first, then the result must be true together with C | |
| 4Without brackets, NOT is done first and only reverses the value right after it | DThe condition was worked out left to right. AND comes first: FALSE AND FALSE is FALSE, then TRUE OR FALSE is TRUE. | |
| 5IF Age < 12 OR Age > 65 AND HasTicket | ENOT (A OR B) | |
| 6TRUE OR FALSE AND FALSE = FALSE | FAND is done before OR, so HasTicket only applies to Age > 65. Brackets are needed: (Age < 12 OR Age > 65) AND HasTicket. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
(A OR B) AND C — Brackets are worked out first. Without them NOT is done first, then AND, then OR. So A OR B AND C means A OR (B AND C), and brackets change that order.IF (Age < 12 OR Age > 65) AND Paid THEN
OUTPUT "Half price"
ENDIFIF NOT (Raining OR Windy) THEN
OUTPUT "Play outside"
ENDIFResult <- (TRUE OR FALSE) AND FALSE
// Result is FALSEResult <- TRUE OR FALSE AND FALSE
// AND first, so Result is TRUEResult <- NOT (TRUE AND FALSE)
// Result is TRUE