Comprehensive Study Guide: Boolean Operators in Computer Science

Lesson Overview and Learning Outcomes

  • Curriculum Context: Learn Like a GEM
  • Subject: Computing
  • Lesson Focus: Boolean Operators
  • Date: 29 September 2026
  • Learning Outcome: By the end of the lesson, learners will be able to evaluate Boolean expressions and justify the use of AND, OR, and NOT in real-world situations.
  • Core Knowledge Components:
    • Boolean operators can be used to create complex conditions for decision-making in pseudocode.
    • AND – The result is TRUE only when both conditions are TRUE.
    • OR – The result is TRUE when at least one condition is TRUE.
    • NOT – Reverses a Boolean value: TRUE becomes FALSE, and FALSE becomes TRUE.

Prior Knowledge Retrieval: Selection Statements

  • Challenge 1 – Core (Meeting Expectations):

    • Pseudocode:text IF score >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF     
    • Prediction for score=65\text{score} = 65: Evaluates to "Pass", because 65≥5065 \ge 50 evaluates to TRUE.
    • Prediction for score=40\text{score} = 40: Evaluates to "Fail", because 40≥5040 \ge 50 evaluates to FALSE.
  • Challenge 2 – Advanced (Above Expectations):

    • Pseudocode:text IF mark >= 90 THEN OUTPUT "Gold" ELSEIF mark >= 75 THEN OUTPUT "Silver" ELSE OUTPUT "Bronze" ENDIF     
    • Selection Branches Count: There are 33 selection branches (IF, ELSEIF, ELSE).
    • Prediction for mark=80\text{mark} = 80: Evaluates to "Silver", because 80≥9080 \ge 90 is FALSE, but 80≥7580 \ge 75 is TRUE.
    • Prediction for mark=60\text{mark} = 60: Evaluates to "Bronze", because both previous conditions evaluate to FALSE.
  • Challenge 3 – Mastery (Push Yourself):

    • Program Specification: A student receives a behaviour grade based on points:
    • If behaviour points equal 100100, output "Outstanding".
    • Else if behaviour points are 8080 or above, output "Good".
    • Otherwise, output "Needs Improvement".
    • Python Implementation:Python solution for behaviour points ```python points = int(input("Enter behaviour points: "))

    if points == 100: print("Outstanding") elif points >= 80: print("Good") else: print("Needs Improvement")     ```

Fundamentals of Boolean Logic

  • Definition of Boolean: Refers to a form of algebra and logic operating exclusively on two truth values: TRUE and FALSE.
  • Purpose in Computing: Boolean operators are applied inside conditional tests (IF statements) to evaluate compound conditions and empower computers to make automated branching decisions.
  • The Three Primary Operators: The fundamental Boolean operators used across programming languages and pseudocode are AND, OR, and NOT.
  • Summary Rules Table:Table 1.4: Boolean operators and their rules
    • AND Operator:
    • Format: One condition on either side (Condition A AND Condition B).
    • Rules: If both conditions are true, the result is true. Otherwise, the result is false.
    • OR Operator:
    • Format: One condition on either side (Condition A OR Condition B).
    • Rules: If one, or both, conditions are true, the result is true. It is false only when both conditions are false.
    • NOT Operator:
    • Format: One condition preceding the operator (NOT Condition A).
    • Rules: If the condition is true, it makes it false. If the condition is false, it makes it true.

The AND Operator

  • Core Operational Principle: The compound expression yields TRUE strictly when both operands evaluate to TRUE. If either operand or both operands evaluate to FALSE, the entire expression resolves to FALSE.
  • Truth Table for AND:
    • True AND True = True
    • True AND False = False
    • False AND True = False
    • False AND False = False
  • Smart Beach Control Room Scenario:
    • Monitored Conditions:
    • Sea Safe = True
    • Lifeguard Present = True
    • Decision Evaluation: Sea Safe AND Lifeguard Present = True AND True = True. The beach safely opens.
    • Predictive Case: If Sea Safe = True and Lifeguard Present = False, the compound test evaluates to False (True AND False = False), preventing opening.
  • Pseudocode Implementation:Pseudocode example of AND operator
  01 total = 97
  02 IF(total > 90 AND total < 100) THEN
  03     OUTPUT("Just in range")
  04 ELSE
  05     OUTPUT("Incorrect amount")
  06 ENDIF
&nbsp;&nbsp;```
  * *Trace with total=97\text{total} = 97:*
    * Sub-condition 1: 97>9097 > 90 evaluates to `TRUE`.
    * Sub-condition 2: 97<10097 < 100 evaluates to `TRUE`.
    * Compound result: `TRUE AND TRUE` evaluates to `TRUE`.
    * System output: `"Just in range"`.

# The OR Operator

* **Core Operational Principle:** The compound expression yields `TRUE` whenever at least one condition evaluates to `TRUE`. The output is `FALSE` exclusively when both operands evaluate to `FALSE`.
* **Truth Table for OR:**
  * `True OR True = True`
  * `True OR False = True`
  * `False OR True = True`
  * `False OR False = False`
* **Smart Library Entry System Scenario:**
  * *Monitored Conditions:*
    * `Library Member = True`
    * `Teacher Permission = False`
  * *Decision Evaluation:* `Library Member OR Teacher Permission` = `True OR False` = `True`. Access is granted.
  * *Predictive Case:* If a student is both a library member and has teacher permission (`True OR True`), the evaluation yields `True`.
* **Pseudocode Implementation:**
&nbsp;&nbsp;![Pseudocode example of OR operator](https://assets.knowt.com/pdf-flow-prod/ab4c82ae-be88-4e6e-a46d-7d9c5fa71c72-figures/15.png)

text 01 total = 50 02 IF(total > 100 OR total < 0) THEN 03 OUTPUT("Out of range") 04 ELSE 05 OUTPUT("Accepted") 06 ENDIF   ```

  • Trace with total=50\text{total} = 50:
    • Sub-condition 1: 50>10050 > 100 evaluates to FALSE.
    • Sub-condition 2: 50<050 < 0 evaluates to FALSE.
    • Compound result: FALSE OR FALSE evaluates to FALSE.
    • System output: The ELSE branch triggers, outputting "Accepted".

The NOT Operator

  • Core Operational Principle: A unary operator applied to a single condition that inverts its Boolean value. A TRUE state is converted to FALSE, and a FALSE state is converted to TRUE.
  • Truth Table for NOT:
    • NOT True = False
    • NOT False = True
  • Smart School Sports System Scenario:
    • Monitored Condition: Injured = False
    • Decision Evaluation: NOT Injured = NOT False = True. The student is eligible to participate.
    • Predictive Case: If a student is injured (Injured = True), evaluating NOT True yields False, preventing sports participation.
  • Pseudocode Implementation:Pseudocode example of NOT operatortext 01 quantity = 0 02 IF NOT(quantity = 0) THEN 03 OUTPUT("Still some remaining") 04 ELSE 05 OUTPUT("No items remaining") 06 ENDIF &nbsp;&nbsp;
    • Trace with quantity=0\text{quantity} = 0:
    • Line 02 applies NOT to a single condition.
    • Sub-condition: quantity=0\text{quantity} = 0 evaluates to TRUE.
    • Inversion: NOT(TRUE) evaluates to FALSE.
    • System output: The ELSE branch triggers, outputting "No items remaining".

Operator Precedence and Evaluation Order

  • Execution Hierarchy: In expressions containing multiple Boolean operators without grouping symbols, operators are evaluated strictly by order of precedence:
    1. Precedence 1: NOT (always evaluates first).
    2. Precedence 2: AND (always evaluates second).
    3. Precedence 3: OR (always evaluates third).   Boolean operator precedence table
  • Modifying Precedence: Brackets (parentheses) must be used to alter the natural execution sequence. Expressions enclosed inside brackets are evaluated prior to any outer operators.

Guided Practice and Application Scenarios

  • Scenario: School Trip Rules:
    • Criteria: A student can join a school trip if they have a permission slip AND have paid the trip fee.
    • Evaluation 1: Permission slip=TRUE\text{Permission slip} = \text{TRUE}, Paid=FALSE\text{Paid} = \text{FALSE} →\rightarrow Can they join? No (True AND False = False).
    • Evaluation 2: Permission slip=FALSE\text{Permission slip} = \text{FALSE}, Paid=TRUE\text{Paid} = \text{TRUE} →\rightarrow Can they join? No (False AND True = False).
    • Evaluation 3: Permission slip=TRUE\text{Permission slip} = \text{TRUE}, Paid=TRUE\text{Paid} = \text{TRUE} →\rightarrow Can they join? Yes (True AND True = True).
    • Justification of Operator Selection: AND is used because both conditions must be true simultaneously. A student requires both parental permission and fee payment. If OR were used, meeting only one condition would allow the student to join, which would improperly permit students without permission or without payment.
  • Challenge 1 – Coding Competition Entry:
    • Criteria: A student can enter the coding competition if they are in Year 8 AND have submitted the registration form.
    • Task: Explain what happens if only one condition is true.
    • Solution: The overall result is FALSE. Students must be in Year 8 and registered; meeting only one condition fails the AND gate, denying entry.
  • Challenge 2 – Library Book Borrowing:
    • Criteria: A student can borrow a library book if they are a Year 8 student OR are a library club member.
    • Operator Required: OR.
    • Justification: OR is used because a student only needs to meet one of the qualifying conditions to borrow a library book.
  • Challenge 3 – Football Tournament Eligibility:
    • Criteria: A student can play in the tournament if they have a sports kit AND have permission AND NOT injured.
    • Operators Used: AND, NOT.
    • Function of NOT: NOT is needed because the student must not be injured to participate. It inverts the Boolean value of injured so that an uninjured student (injured=FALSE\text{injured} = \text{FALSE}) becomes TRUE, satisfying the participation requirement while disqualifying injured individuals (injured=TRUE→NOT TRUE=FALSE\text{injured} = \text{TRUE} \rightarrow \text{NOT TRUE} = \text{FALSE}).

Independent Practice: Spatial Analysis and Evaluation

  • Applying (Levels C/D) – Range Check Algorithm:
    • Inspected Code: Lines 01–06 evaluating IF(total > 100 OR total < 0) with total=50\text{total} = 50.
    • Conditions Tested: total>100\text{total} > 100 and total<0\text{total} < 0.
    • Function of OR: Requires only one of the sub-conditions to be true for the compound condition to evaluate to true.
    • Predicted Output: "Accepted". Because 50>10050 > 100 is FALSE and 50<050 < 0 is FALSE, FALSE OR FALSE evaluates to FALSE, transferring control to ELSE.
  • Analyzing (Levels A/B) – Algorithm Intent and Boundary Testing:
    • Algorithm Purpose: To check whether the numerical value of total falls outside the valid range (strictly less than 00 or strictly greater than 100100).
    • Tracing total=100\text{total} = 100:
    • Step 1: 100>100→False100 > 100 \rightarrow \text{False}
    • Step 2: 100<0→False100 < 0 \rightarrow \text{False}
    • Step 3: Compound result is False OR False = False.
    • Step 4: Output produces "Accepted".
    • Explanation: The boundary value 100100 is neither greater than 100100 nor less than 00, meaning it is within the accepted range.
  • Evaluating (Level A*) – Colour Check Algorithm:Pseudocode example of colour checking
    • Inspected Code:text INPUT colour IF colour = "red" OR colour = "blue" THEN value = 1 ELSE value = 2 ENDIF &nbsp;&nbsp;&nbsp;&nbsp;
    • Impact of OR Operator: Makes the conditional test true if the user input matches either "red" or "blue".
    • Outcome for Input "blue": Sets value=1\text{value} = 1 because "blue" matches one of the valid conditions in the OR expression.
    • Alternative Input Generating value=2\text{value} = 2: Entering "green" produces value=2\text{value} = 2 because "green" is neither "red" nor "blue", causing both comparisons to evaluate to FALSE.

Independent Practice: Verbal Analysis and Comparative Evaluation

  • Mechanics of Decision-Making: Boolean operators help computers make decisions by testing whether defined criteria are true or false, directing the execution pipeline down specific algorithmic pathways based on the resulting logic state.
  • Comparative Trade-Offs of Boolean Operators:
    • AND Operator: Highly accurate and secure by enforcing multiple mandatory prerequisites; however, it is strict and will fail if even one minor criterion is unfulfilled.
    • OR Operator: Highly flexible by accommodating multiple acceptable alternatives; however, it risks allowing unwanted outcomes if conditions are defined too permissively.
    • NOT Operator: Essential for filtering out exclusions and handling exceptions; however, stacking negative logic can cause confusion in complex programs.
  • Judgment on Real-World Utility:
    • AND is the most critical operator for high-stakes real-world systems because mission-critical applications require multiple independent verifications before authorizing actions.
    • Everyday Technology Example: Online banking security systems require a valid password AND an SMS/biometric verification code before granting account access. Using AND guarantees that meeting only one security criterion is insufficient, maintaining strict data integrity.

Questions & Discussion

  • Turn and Talk Discussion:
    • Question: Ajman Beach can only open if the sea is safe and a lifeguard is present. Why does the beach need to check more than one condition before opening?
    • Answer: Checking multiple conditions via an AND operation is essential for safety compliance. If the sea is safe but no lifeguard is on duty, swimmers are unprotected during emergencies. Conversely, if a lifeguard is present but the sea is rough, conditions remain hazardous. Both factors must be satisfied simultaneously to prevent preventable accidents.
  • Exit Ticket – SHOW ME:
    • Question: A student can access a school computer only if they know the username and password. Which Boolean operator is being used and why?
    • Answer: The AND operator is being used because both credentials must be verified as true before access is granted.
  • Exit Ticket – THINK BACK:
    • Question 1: Which Boolean operator requires all conditions to be TRUE?
    • Answer: AND.
    • Question 2: Which Boolean operator requires at least one condition to be TRUE?
    • Answer: OR.
    • Question 3: What does the NOT operator do?
    • Answer: It reverses a Boolean value: TRUE becomes FALSE and FALSE becomes TRUE.
  • Exit Ticket – THINK FORWARD:
    • Question: How might AND, OR, and NOT help a computer make decisions in a larger program?
    • Answer: In larger software systems, these operators can be combined into compound conditional expressions and control structures to manage complex logic, manage user permissions, validate data ranges, and coordinate system behaviors based on multiple dynamic inputs.