Logical operator OR

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

Logical operator OR

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Day ← "Sun". What is the result of: Day = "Sat" OR Day = "Sun"
A TRUE, because the second condition is TRUE
B FALSE, because the first condition is FALSE
2. Which statement about OR is correct?
A It is only FALSE when both conditions are FALSE
B It is only TRUE when both conditions are TRUE
3. Which line correctly checks for a weekend day?
A IF Day = "Sat" OR "Sun" THEN
B IF Day = "Sat" OR Day = "Sun" THEN
4. Mark ← 120. What is the result of: Mark < 0 OR Mark > 100
A TRUE, because Mark > 100 is TRUE
B FALSE, because Mark < 0 is FALSE
5. Which condition is TRUE for a value outside the range 1 to 10?
A Num < 1 AND Num > 10
B Num < 1 OR Num > 10

Match the Pairs

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

Left columnRight column
1Day = "Sat" OR Day = "Sun" ATRUE if the day is Saturday or Sunday (the weekend)
2Mark < 0 OR Mark > 100 BAND is used where OR is needed. No score can be below 0 and above 100 at once, so the condition is never TRUE. It should be OR.
3OR is only FALSE when both conditions are FALSE Cx <- 10 IF x > 5 OR x > 8 THEN
4OR is still TRUE when both conditions are TRUE DTRUE if the mark is outside the valid range 0 to 100
5IF Day = "Sat" OR "Sun" THEN EIF Age < 5 OR Age > 65 THEN
6IF Score < 0 AND Score > 100 THEN FEach side of OR must be a full condition. "Sun" on its own is not a condition. It should be Day = "Sat" OR Day = "Sun".

Definitions

OR

Fill in the Blanks

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

1.
IF Day = "Sat" __ Day = "Sun" THEN OUTPUT "Weekend" ENDIF
2.
IF Mark < 0 __ Mark > 100 THEN OUTPUT "Invalid mark" ENDIF
3.
IF Age < 5 OR Age _ 65 THEN OUTPUT "Free ticket" ENDIF
4.
Wet <- TRUE Cold <- TRUE OUTPUT Wet __ Cold
5.
IF Letter = "a" OR Letter = "e" ____ OUTPUT "Vowel" ENDIF

Spot the Error

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

Question 1
A DECLARE Day : STRING
B OUTPUT "Enter the day"
C INPUT Day
D IF Day = "Sat" AND Day = "Sun"
E THEN OUTPUT "Weekend"
F ENDIF
Question 2
A INPUT Mark
B IF Mark > 0 OR Mark < 100
C THEN OUTPUT "Invalid"
D ENDIF
Question 3
A Age ← 15
B Member ← TRUE
C IF Age < 16 OR Member == TRUE
D THEN OUTPUT "Cheap entry"
E ENDIF
Question 4
A DECLARE Ans : CHAR
B INPUT Ans
C IF Ans = "Y" OR "y"
D THEN OUTPUT "Yes"
E ENDIF
Question 5
A INPUT Temp
B OUTPUT "Checking"
C IF Temp < 5 OR Temp < 35
D THEN OUTPUT "Extreme"
E ELSE OUTPUT "Normal"
F ENDIF

Answer Key

Logical operator OR
Section A: Quick Questions
Q1
A — TRUE, because the second condition is TRUE
Q2
A — It is only FALSE when both conditions are FALSE
Q3
B — IF Day = "Sat" OR Day = "Sun" THEN
Q4
A — TRUE, because Mark > 100 is TRUE
Q5
B — Num < 1 OR Num > 10
Section B: Match the Pairs
Q1
Day = "Sat" OR Day = "Sun" → TRUE if the day is Saturday or Sunday (the weekend)
Q2
Mark < 0 OR Mark > 100 → TRUE if the mark is outside the valid range 0 to 100
Q3
OR is only FALSE when both conditions are FALSE → IF Age < 5 OR Age > 65 THEN
Q4
OR is still TRUE when both conditions are TRUE → x <- 10 IF x > 5 OR x > 8 THEN
Q5
IF Day = "Sat" OR "Sun" THEN → Each side of OR must be a full condition. "Sun" on its own is not a condition. It should be Day = "Sat" OR Day = "Sun".
Q6
IF Score < 0 AND Score > 100 THEN → AND is used where OR is needed. No score can be below 0 and above 100 at once, so the condition is never TRUE. It should be OR.
Section C: Definitions
Q1
OR — Joins two conditions. The result is TRUE when at least one condition is TRUE, e.g. Day = "Sat" OR Day = "Sun". It is only FALSE when both conditions are FALSE.
Section D: Fill in the Blanks
Q1
IF Day = "Sat" OR Day = "Sun" THEN OUTPUT "Weekend" ENDIF
Q2
IF Mark < 0 OR Mark > 100 THEN OUTPUT "Invalid mark" ENDIF
Q3
IF Age < 5 OR Age > 65 THEN OUTPUT "Free ticket" ENDIF
Q4
Wet <- TRUE Cold <- TRUE OUTPUT Wet OR Cold
Q5
IF Letter = "a" OR Letter = "e" THEN OUTPUT "Vowel" ENDIF
Section E: Spot the Error
Q1
D — Day cannot be both "Sat" and "Sun" at once, so AND is never TRUE. OR is needed: IF Day = "Sat" OR Day = "Sun".
Q2
B — The conditions are the wrong way round. Every number is above 0 or below 100, so every mark would be invalid. It should be IF Mark < 0 OR Mark > 100.
Q3
C — Cambridge pseudocode compares with a single =, not ==. The line should be IF Age < 16 OR Member = TRUE. Both conditions are TRUE here and OR is still TRUE.
Q4
C — OR joins two full conditions. "y" on its own is not a condition. It should be IF Ans = "Y" OR Ans = "y".
Q5
C — The second condition should test for values above the range. Temp < 35 is TRUE for 20, so a normal temperature would be Extreme. It should be Temp > 35.