Skip to content
IGCSE·Tuition
Computer Science · Lesson

Logical AND versus everyday language

In conversation, 'and' and 'or' bend to fit the meaning, but a computer needs exactly one reading.

On this page
  1. Where does ordinary language mislead?
  2. How to translate a sentence
  3. Worked example 1
  4. Worked example 2
  5. The mistake to watch for
  6. Check yourself
  7. Where this leads next

In logic, AND is true only when both parts are true, and OR is true when at least one part is true. In everyday language the same words can mean something looser, which is why a sentence must be turned into brackets before it becomes a condition.

This lesson uses the operators from evaluating expressions and the case checks from comparing expressions. It closes the teaching lessons of the Boolean logic module.

Where does ordinary language mislead?

There are three common traps.

  1. “And” used to list groups. “Free entry for children under 5 and adults over 65” lists two groups. One person is never in both, so the condition needs OR.
  2. “Or” meaning one or the other. “You may have tea or coffee” usually excludes both. Logical OR allows both, and XOR excludes both.
  3. Mixed AND and OR with no brackets. “The door is open and the system is not armed or the panic button is pressed” has two readings.

How to translate a sentence

  1. Name each simple statement with a letter.
  2. Mark the operators in the sentence: and, or, not.
  3. Ask what is being grouped and write brackets.
  4. Test a case where different readings would disagree.

Worked example 1

Rule: “Free entry for visitors under 5 and over 65.”

Wrong translation: IF (Age < 5) AND (Age > 65) THEN. Test Age = 3: (3 < 5) is true and (3 > 65) is false, so true AND false = false. A three-year-old would be refused.

Correct: IF (Age < 5) OR (Age > 65) THEN. Test Age = 3: true OR false = true.

Test Age = 30: false OR false = false. Test Age = 70: false OR true = true.

Worked example 2

Rule: “The alarm sounds if the door is open and the system is not armed or the panic button is pressed.”

Let D = door open, S = system armed, P = panic button pressed.

  • Reading 1: (D AND NOT S) OR P
  • Reading 2: D AND (NOT S OR P)

Test D = 0, S = 0, P = 1 (door closed, system off, panic pressed).

Reading 1: (0 AND 1) OR 1 = 0 OR 1 = 1. Reading 2: 0 AND (1 OR 1) = 0 AND 1 = 0.

The readings give different results, so the sentence is ambiguous. Reading 1 sounds the alarm whenever panic is pressed, which is probably the intention, but only the person writing the rule can say. In a program you must choose, and brackets record the choice:

IF (Door = TRUE AND Armed = FALSE) OR Panic = TRUE THEN
   OUTPUT "ALARM"
ENDIF

The mistake to watch for

Mistaken working: “The rule says ‘and’, so I will use AND everywhere.”

The word in the sentence is not always the operator the condition needs. Decide from the meaning, then check with a case. A good habit is to test one input that should clearly pass and one that should clearly fail.

Check yourself

1. “Visitors may enter if they have a ticket and a pass or are staff.” Write two bracketed readings.

Show answer

Let T = ticket, P = pass, S = staff. Reading 1: (T AND P) OR S. Reading 2: T AND (P OR S). Test T = 0, P = 0, S = 1: reading 1 gives 1, reading 2 gives 0, so they differ.

2. “Not hot and humid.” Give two readings and a case where they differ.

Show answer

Let H = hot, U = humid. Reading 1: NOT (H AND U). Reading 2: (NOT H) AND U. Test H = 1, U = 0: reading 1 gives NOT 0 = 1. Reading 2 gives 0 AND 0 = 0. They differ.

3. A menu says “choose soup or salad”. Which gate matches the intended meaning, if you may not take both?

Show answer

XOR, because it is 1 only when exactly one choice is selected. OR would also accept both.

Where this leads next

Finish the module with the Boolean logic practice set, which mixes all five skills. The safe Python reasoning sandbox lets you test conditions such as the alarm rule safely.

Turning words into precise conditions is a skill our teachers coach one example at a time in online one-to-one Computer Science tuition.

Questions people ask

Is the word 'or' in English the same as OR in logic?

Not always. In logic, OR is true when at least one input is true, including both. In everyday speech, 'tea or coffee' usually means one or the other, which is XOR. When a question says 'or', decide which meaning is intended from the context.

Why does 'under 5 and over 65' never work as a condition?

No age is both under 5 and over 65 at the same time, so AND is always false. In speech 'and' lists two groups, but in logic you need OR to include either group. Always ask whether one value must satisfy both parts at once.

How do I handle a sentence that could mean two things?

Write each reading with brackets, then test a case where the readings give different outputs. In an exam, state the reading you use, and follow the brackets or wording the question gives. Brackets remove the ambiguity.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you understand the logic yet find word problems hard to turn into conditions, a one-to-one teacher can practise translating sentences with you until the brackets come naturally.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parents: enquire here

  • 9,000+ students helped through our service
  • 9+ years helping IGCSE students