Writing precise conditions (7a)

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

Writing precise conditions (7a)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which condition is written precisely enough for an exam answer?
A Age >= 18
B Age is old enough
2. Which condition uses a relational symbol instead of words?
A Score > HighScore
B Score is greater than HighScore
3. Which condition names the exact variable being tested?
A IF the mark is high enough THEN
B IF Mark >= 50 THEN
4. A password must have at least 8 characters. Which condition is correct?
A LENGTH(Password) >= 8
B LENGTH(Password) > 8
5. A user must be older than 12. Which condition is correct?
A Age >= 12
B Age > 12

Match the Pairs

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

Left columnRight column
1Score >= 50 AAge > 16
2Age <> 18 BTemperature >= 100
3To test that a student must be older than 16 (16 itself does not count), write the symbol and the exact value CA precise condition: true when Score is 50 or more, so 50 itself passes
4To test that a temperature is at least 100, include 100 itself by using the symbol for greater than or equal to DA precise condition: true when Age is anything other than 18
5IF Mark is greater than 50 THEN EThe condition uses words instead of a relational symbol, so it is too vague and loses marks. It should be IF Mark > 50 THEN.
6IF Age >= 18 THEN (when the rule says over 18) FThe wrong symbol is used. 'Over 18' means 18 does not count, so it should be Age > 18, not Age >= 18.

Definitions

Age >= 18

Fill in the Blanks

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

1.
IF Age __ 18 THEN OUTPUT "Adult" ENDIF
2.
IF ____ > 40 THEN OUTPUT "Mark above 40" ENDIF
3.
IF Quantity _ 10 THEN OUTPUT "Low stock" ENDIF
4.
IF Age __ 5 THEN OUTPUT "Free entry" ENDIF
5.
IF Score >= 0 ___ Score <= 100 THEN OUTPUT "Valid" ENDIF

Spot the Error

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

Question 1
A INPUT Mark
B Pass ← FALSE
C IF Mark is at least 50 THEN
D Pass ← TRUE
E ENDIF
Question 2
A REPEAT
B OUTPUT "Enter a number"
C INPUT Num
D UNTIL Num is between 1 and 10
Question 3
A IF Temp greater than 30 THEN
B OUTPUT "Hot"
C ENDIF
Question 4
A INPUT Items
B // Free delivery for 5 or more
C Free ← FALSE
D IF Items > 5 THEN
E Free ← TRUE
F ENDIF
Question 5
A INPUT Height
B IF the height >= 140 THEN
C OUTPUT "Can ride"
D ENDIF

Answer Key

Writing precise conditions (7a)
Section A: Quick Questions
Q1
A — Age >= 18
Q2
A — Score > HighScore
Q3
B — IF Mark >= 50 THEN
Q4
A — LENGTH(Password) >= 8
Q5
B — Age > 12
Section B: Match the Pairs
Q1
Score >= 50 → A precise condition: true when Score is 50 or more, so 50 itself passes
Q2
Age <> 18 → A precise condition: true when Age is anything other than 18
Q3
To test that a student must be older than 16 (16 itself does not count), write the symbol and the exact value → Age > 16
Q4
To test that a temperature is at least 100, include 100 itself by using the symbol for greater than or equal to → Temperature >= 100
Q5
IF Mark is greater than 50 THEN → The condition uses words instead of a relational symbol, so it is too vague and loses marks. It should be IF Mark > 50 THEN.
Q6
IF Age >= 18 THEN (when the rule says over 18) → The wrong symbol is used. 'Over 18' means 18 does not count, so it should be Age > 18, not Age >= 18.
Section C: Definitions
Q1
Age >= 18 — A precise condition uses a relational symbol and exact values, like Age >= 18. Words such as 'Age is old enough' or 'greater than' are too vague and lose marks.
Section D: Fill in the Blanks
Q1
IF Age >= 18 THEN OUTPUT "Adult" ENDIF
Q2
IF Mark > 40 THEN OUTPUT "Mark above 40" ENDIF
Q3
IF Quantity < 10 THEN OUTPUT "Low stock" ENDIF
Q4
IF Age <= 5 THEN OUTPUT "Free entry" ENDIF
Q5
IF Score >= 0 AND Score <= 100 THEN OUTPUT "Valid" ENDIF
Section E: Spot the Error
Q1
C — The condition uses words ('is at least') instead of a relational symbol. It should be IF Mark >= 50 THEN.
Q2
D — 'is between 1 and 10' is wording, not a precise condition. Use symbols and repeat the variable: UNTIL Num >= 1 AND Num <= 10.
Q3
A — 'greater than' is written in words. A precise condition uses the symbol: IF Temp > 30 THEN.
Q4
D — '5 or more' includes 5, so the condition needs >=. Using > wrongly leaves out exactly 5 items. It should be IF Items >= 5 THEN.
Q5
B — The condition must name the exact variable, Height, as it was declared and input. 'the height' is not an identifier. It should be IF Height >= 140 THEN.