Joining conditions with AND and OR

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Joining conditions with AND and OR

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A rule says: IF it is Saturday AND it is sunny THEN go to the beach. It is Saturday but it is raining. Do you go to the beach?
A Yes, because one condition is true
B No, because AND needs both conditions to be true
2. A rule says: IF it is Saturday OR it is sunny THEN go to the beach. It is Monday and it is sunny. Do you go to the beach?
A Yes, because OR needs at least one condition to be true
B No, because it is not Saturday
3. Which joining word is true only when both conditions are true?
A OR
B AND
4. Which joining word is true when at least one condition is true?
A OR
B AND
5. You can enter the school disco only if you have a ticket AND you are in Year 5 or 6. Which condition is written correctly?
A IF has ticket AND year is 5 or 6 THEN enter
B IF has ticket OR year is 5 or 6 THEN enter

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1IF it is Saturday AND it is sunny THEN AThe steps run when at least one condition is true: rain, wind, or both.
2IF it is raining OR it is windy THEN BIF it is raining OR it is very sunny THEN take umbrella
3Use AND when both things must be true before the school bag is packed for swimming CThe steps run only when both conditions are true: it is Saturday and it is sunny.
4Use OR when either one of two things is enough to take an umbrella DIF it is Tuesday AND it is swimming day THEN pack towel
5IF it is Saturday OR it is sunny THEN go to the beach (only on sunny Saturdays) EOR lets the steps run on any Saturday or any sunny day. It should be AND because both must be true.
6IF score > 50 AND score < 20 THEN say "Try again" FNo score can be both over 50 and under 20, so AND is never true. It should be OR if either one is enough.

Definitions

AND / OR

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF day = "Saturday" ___ weather = "sunny" THEN SAY "Go to the beach" END IF
2.
IF day = "Saturday" __ day = "Sunday" THEN SAY "No school today" END IF
3.
IF age >= 10 ___ age <= 12 THEN SAY "Join the group" END IF
4.
__ ticket = "yes" AND money > 5 THEN SAY "Enter the show" END IF
5.
IF mark < 40 __ mark > 90 THEN SAY "Check this mark" END IF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A SET Saturday TO true
B SET sunny TO false
C IF Saturday OR sunny THEN
D SAY Go to the beach
Question 2
A IF raining AND cold THEN
B SAY Take a coat
C ELSE
D SAY No coat needed
Question 3
A INPUT age
B IF age>=10 AND <=12 THEN
C SAY Join the Year 5-6 club
D ELSE
E SAY Not this time
Question 4
A IF homework, chores THEN
B SAY You can play games
C ELSE
D SAY Finish your jobs first
Question 5
A SET hasTicket TO true
B SET hasPass TO false
C SET inside TO no
D IF hasTicket AND hasPass THEN
E SET inside TO yes

Answer Key

Joining conditions with AND and OR
Section A: Quick Questions
Q1
B — No, because AND needs both conditions to be true
Q2
A — Yes, because OR needs at least one condition to be true
Q3
B — AND
Q4
A — OR
Q5
A — IF has ticket AND year is 5 or 6 THEN enter
Section B: Match the Pairs
Q1
IF it is Saturday AND it is sunny THEN → The steps run only when both conditions are true: it is Saturday and it is sunny.
Q2
IF it is raining OR it is windy THEN → The steps run when at least one condition is true: rain, wind, or both.
Q3
Use AND when both things must be true before the school bag is packed for swimming → IF it is Tuesday AND it is swimming day THEN pack towel
Q4
Use OR when either one of two things is enough to take an umbrella → IF it is raining OR it is very sunny THEN take umbrella
Q5
IF it is Saturday OR it is sunny THEN go to the beach (only on sunny Saturdays) → OR lets the steps run on any Saturday or any sunny day. It should be AND because both must be true.
Q6
IF score > 50 AND score < 20 THEN say "Try again" → No score can be both over 50 and under 20, so AND is never true. It should be OR if either one is enough.
Section C: Definitions
Q1
AND / OR — AND is true only when both conditions are true. OR is true when at least one is true. Saturday AND sunny needs both; Saturday OR sunny needs just one.
Section D: Fill in the Blanks
Q1
IF day = "Saturday" AND weather = "sunny" THEN SAY "Go to the beach" END IF
Q2
IF day = "Saturday" OR day = "Sunday" THEN SAY "No school today" END IF
Q3
IF age >= 10 AND age <= 12 THEN SAY "Join the group" END IF
Q4
IF ticket = "yes" AND money > 5 THEN SAY "Enter the show" END IF
Q5
IF mark < 40 OR mark > 90 THEN SAY "Check this mark" END IF
Section E: Spot the Error
Q1
C — The plan needs BOTH things true, so it must use AND. With OR, it is Saturday so the beach plan would run even though it is not sunny. It should be: IF Saturday AND sunny THEN.
Q2
A — You need a coat if it is raining or if it is cold, so just one condition is enough. That needs OR. With AND, you would only get a coat when both are true. It should be: IF raining OR cold THEN.
Q3
B — Each side of AND is a full condition of its own, so the second one needs the variable too. It should be: IF age>=10 AND age<=12 THEN.
Q4
A — Conditions are joined with the word AND (or OR), not with a comma. It should be: IF homework AND chores THEN.
Q5
D — A person gets in with a ticket or a pass, so only one needs to be true. That needs OR. With AND, this person (who has a ticket but no pass) would be kept out. It should be: IF hasTicket OR hasPass THEN.