Logical Operators Formula

Logical operators are operators that combine or modify boolean expressions: AND (true only when both operands are true), OR (true when at least one.

The Formula

AND: T∧T=T; OR: F∨T=T; NOT: ¬T=F

When to use: AND is strict (both must be true), OR is flexible (either works), NOT flips the result.

Quick Example

x > 0 AND x < 10 is True only when x is between 1 and 9 (e.g., x=5 is True, x=11 is False).

What This Formula Means

Operators that combine or modify boolean expressions: AND (true only when both operands are true), OR (true when at least one operand is true), and NOT (reverses a boolean value from true to false or vice versa).

AND is strict (both must be true), OR is flexible (either works), NOT flips the result.

Formal View

Logical operators on boolean values: conjunction ABA \land B (AND), disjunction ABA \lor B (OR), negation ¬A\lnot A (NOT). They satisfy De Morgan's laws: ¬(AB)=¬A¬B\lnot(A \land B) = \lnot A \lor \lnot B and ¬(AB)=¬A¬B\lnot(A \lor B) = \lnot A \land \lnot B.

Worked Examples

Example 1

medium
Evaluate A AND NOT B OR CA \text{ AND NOT } B \text{ OR } C for A=A=True, B=B=True, C=C=False, using standard precedence.

Answer

False\text{False}

First step

1
NOT B = NOT True = False.

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

medium
Use De Morgan to rewrite: NOT(x>0 OR y>0)\text{NOT}(x > 0 \text{ OR } y > 0).

Example 3

medium
Identify the bug: `if (x = 0 OR 1 OR 2)` is meant to test whether x is 0, 1, or 2.

Common Mistakes

  • Confusing AND with OR in complex conditions, reversing the intended logic - Fix this by naming the input, process, output, evidence, and checking "Am I changing a messy task into a clearer problem structure that can be solved step by step or reused?" before using the concept.
  • Forgetting operator precedence—NOT binds before AND, which binds before OR—leading to unexpected results without parentheses - Fix this by naming the input, process, output, evidence, and checking "Am I changing a messy task into a clearer problem structure that can be solved step by step or reused?" before using the concept.
  • Using natural language intuition that fails in code: 'x is 5 or 10' must be written as 'x == 5 OR x == 10', not 'x == 5 OR 10' - Fix this by naming the input, process, output, evidence, and checking "Am I changing a messy task into a clearer problem structure that can be solved step by step or reused?" before using the concept.
  • Using logical operators from a keyword alone - Signal words like decompose, pattern, abstract only point to a possible model; the computing structure must match too.

Why This Formula Matters

Logical operators are used in every conditional statement, database query, search filter, and access control rule in programming. They are the tools that turn simple yes/no questions into sophisticated decision logic.

Frequently Asked Questions

What is the Logical Operators formula?

Operators that combine or modify boolean expressions: AND (true only when both operands are true), OR (true when at least one operand is true), and NOT (reverses a boolean value from true to false or vice versa).

How do you use the Logical Operators formula?

AND is strict (both must be true), OR is flexible (either works), NOT flips the result.

Why is the Logical Operators formula important in CS Thinking?

Logical operators are used in every conditional statement, database query, search filter, and access control rule in programming. They are the tools that turn simple yes/no questions into sophisticated decision logic.

What do students get wrong about Logical Operators?

AND requires ALL conditions true; OR only requires ONE — easy to confuse.

What should I learn before the Logical Operators formula?

Before studying the Logical Operators formula, you should understand: boolean logic, selection.