Boolean Logic
To turn a written scenario into Boolean logic, first find every separate condition that can be true or false. Give each condition a letter, where 1 means the condition is true and 0 means it is false. Next, identify any of the connectives and, or and not; they show how the conditions are combined.
For example, a library's silent-study sign lights up when a study session is booked and the room is not being cleaned, or when an exam is taking place. Let B mean the session is booked, C mean the room is being cleaned, and E mean an exam is taking place. "Not being cleaned" becomes NOT C. The booking and the inverted cleaning condition are joined by AND, while the exam is an alternative, so it is joined by OR. The expression is (B AND NOT C) OR E.
Use brackets to show which conditions are grouped together, and remember that a letter is just a label for a condition, not a number to calculate with. If both a booking and an exam are happening, OR still makes the overall result true: OR includes the case where both alternatives are true.
Once it is written, the whole expression acts like one condition of its own: it gives 1 when the sign should light up and 0 when it should not.
The same three operators can appear in program conditions such as if statements, but those are covered in a separate subtopic.
OCR GCSE Computer Science · Boolean Logic