Writing precise conditions (7c)

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

Writing precise conditions (7c)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which condition is written precisely enough to earn the mark in an IGCSE answer?
A IF Age >= 18 THEN
B IF Age is 18 or more THEN
2. Which condition correctly tests that Mark is not zero?
A Mark is not zero
B Mark <> 0
3. Which condition correctly checks that Name is Ali?
A Name = "Ali"
B Name is Ali
4. A decision diamond in a flowchart needs a condition. Which should be written inside it?
A Score > 50
B Is the score greater than 50?
5. True or false: 'x is greater than y' is accepted as a condition in pseudocode.
A True
B False

Match the Pairs

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

Left columnRight column
1Age >= 18 AThe condition is written in words. It should use a symbol: IF Age >= 18 THEN.
2Mark <> 0 BA precise condition that is true when Age is 18 or more
3To test whether a name is Ali, use the = symbol with the text in double quotes, not words CThe condition is written in words. It should be IF Mark <> 0 THEN, using the not equal symbol.
4A decision in a flowchart must also hold a symbol condition, not a sentence DAge >= 18 ?
5IF Age is 18 or more THEN EA precise condition that is true when Mark is not zero
6IF Mark is not zero THEN FName = "Ali"

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 Mark __ 0 THEN OUTPUT "Has a mark" ENDIF
3.
IF Name _ "Ali" THEN OUTPUT "Hello Ali" ENDIF
4.
Flowchart decision diamond: Age _ 18 ?
5.
IF Age >= 18 ___ Age <= 65 THEN

Spot the Error

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

Question 1
A OUTPUT "Enter age"
B INPUT Age
C IF Age is 18 or more THEN
D OUTPUT "Adult"
E ENDIF
Question 2
A DECLARE Mark : INTEGER
B REPEAT
C INPUT Mark
D UNTIL Mark is from 0 to 100
Question 3
A INPUT Mark
B Total ← 100
C IF Mark is not zero THEN
D Average ← Total / Mark
E ENDIF
Question 4
A INPUT Name
B IF Name is Ali THEN
C OUTPUT "Welcome back"
D ENDIF
Question 5
A WHILE Count is below 10 DO
B Count ← Count + 1
C ENDWHILE

Answer Key

Writing precise conditions (7c)
Section A: Quick Questions
Q1
A — IF Age >= 18 THEN
Q2
B — Mark <> 0
Q3
A — Name = "Ali"
Q4
A — Score > 50
Q5
B — False
Section B: Match the Pairs
Q1
Age >= 18 → A precise condition that is true when Age is 18 or more
Q2
Mark <> 0 → A precise condition that is true when Mark is not zero
Q3
To test whether a name is Ali, use the = symbol with the text in double quotes, not words → Name = "Ali"
Q4
A decision in a flowchart must also hold a symbol condition, not a sentence → Age >= 18 ?
Q5
IF Age is 18 or more THEN → The condition is written in words. It should use a symbol: IF Age >= 18 THEN.
Q6
IF Mark is not zero THEN → The condition is written in words. It should be IF Mark <> 0 THEN, using the not equal symbol.
Section C: Definitions
Q1
Age >= 18 — Write a condition with symbols such as >=, <> and =, not words. Age >= 18 is correct; 'Age is 18 or more' is not accepted. This applies in pseudocode and flowcharts.
Section D: Fill in the Blanks
Q1
IF Age >= 18 THEN OUTPUT "Adult" ENDIF
Q2
IF Mark <> 0 THEN OUTPUT "Has a mark" ENDIF
Q3
IF Name = "Ali" THEN OUTPUT "Hello Ali" ENDIF
Q4
Flowchart decision diamond: Age < 18 ?
Q5
IF Age >= 18 AND Age <= 65 THEN
Section E: Spot the Error
Q1
C — The condition is written in words. Exam answers must use symbols, so it should be IF Age >= 18 THEN.
Q2
D — A range check must be written precisely with relational and logical operators. It should be UNTIL Mark >= 0 AND Mark <= 100.
Q3
C — 'is not zero' is words, not a precise condition. Use the not-equal symbol: IF Mark <> 0 THEN.
Q4
B — Text must be compared with the = symbol and the literal must be in double quotes. It should be IF Name = "Ali" THEN.
Q5
A — A loop condition must use symbols, not words. It should be WHILE Count < 10 DO.