Boolean logic

GCSE Computer Science · Unit 4: Programming

Boolean logic notes

Fact-checked by a second, independent AI review.

Overview of how to use Boolean logic in programming: operators, evaluation of expressions, and how this is tested in GCSE questions for OCR/AQA Computer Science. Focus on truth tables, precedence, and converting real-world situations into logical expressions.

Boolean variables
Variables that hold true or false values used in expressions and decisions.
Boolean operators
AND (both sides true), OR (at least one true), NOT (negates a value); used to build logical expressions.
Truth tables
Tables showing all possible input values and the resulting output for a Boolean expression.
Precedence and parentheses
NOT has highest precedence, then AND, then OR; use parentheses to group expressions clearly.
Evaluating Boolean expressions
Work from inside parentheses, apply operators in order, determine final true/false value.

Remember it: Not flips, And narrows, Or broadens: remember the order to quickly evaluate any logic expression.

Exam tip: Exam markers want you to convert real situations into Boolean expressions, read questions for required truth values, and show clear step-by-step evaluation or truth tables to justify the final answer.

Syllabus checklist

  • Boolean logic: core ideas
  • Terms and typical exam questions for "Programming" in GCSE Computer Science (OCR/AQA)

Practice questions

  1. 1. What is the result of A AND B if A=true and B=false?

    Answer checked

    Show answer

    Answer: false. AND requires both inputs true; one is false, so the result is false.

  2. 2. X OR NOT X is always ____.

    Answer checked

    Show answer

    Answer: True. X OR NOT X is a tautology and always true.

  3. 3. In Boolean logic, a variable that can be only true or false is called a ____.

    Answer checked

    Show answer

    Answer: boolean. Such a variable is called a boolean.

  4. 4. NOT (A AND B) equals to ____.

    Answer checked

    Show answer

    Answer: NOT A OR NOT B. De Morgan's law: NOT (A AND B) = NOT A OR NOT B.

  5. 5. Compute the value of the expression (1 AND 0) OR (1 AND 1) = ____.

    Answer checked

    Show answer

    Answer: 1. (1 AND 0) = 0; (1 AND 1) = 1; 0 OR 1 = 1.

Practise boolean logic as a game

Hearts, combos, streaks and an AI tutor that explains every answer. Start free.

Start free

More from Unit 4: Programming