Keywords in upper case

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

Keywords in upper case

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line is written correctly in Cambridge pseudocode?
A if Score > 50 then
B IF Score > 50 THEN
2. Which line correctly finishes an IF statement?
A endif
B ENDIF
3. Which loop header follows the keyword rule?
A WHILE Count < 10 DO
B while Count < 10 do
4. Which is the correct way to close a WHILE loop?
A ENDWHILE
B Endwhile
5. Which variable name is allowed in pseudocode?
A Total
B IF

Match the Pairs

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

Left columnRight column
1IF Score >= 50 THEN OUTPUT "Pass" ENDIF AWHILE is a keyword, so it cannot be used as an identifier. Use a name such as Counter instead.
2WHILE Count < 5 DO Count ← Count + 1 ENDWHILE BIF Age >= 16 THEN OUTPUT "Adult" ENDIF
3Every keyword in Cambridge pseudocode, including the one that closes a selection, is written in upper case CDECLARE Total : INTEGER
4A keyword can never be used as an identifier name, so a variable must have a different name such as Total DCorrect: WHILE, DO and ENDWHILE are keywords in upper case, while Count is an identifier in Pascal case
5if Score >= 50 THEN OUTPUT "Pass" endif ECorrect: the keywords IF, THEN, OUTPUT and ENDIF are all written in upper case
6DECLARE WHILE : INTEGER FThe keywords if and endif are in lower case. They should be IF and ENDIF.

Definitions

IF

Fill in the Blanks

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

1.
__ Mark >= 50 THEN OUTPUT "Pass" ENDIF
2.
IF Mark >= 50 THEN OUTPUT "Pass" _____
3.
_____ Count <= 5 DO Count ← Count + 1 ENDWHILE
4.
WHILE Count <= 5 DO Count ← Count + 1 ________
5.
IF Age >= 18 THEN ______ "Adult" ENDIF

Spot the Error

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

Question 1
A DECLARE Score : INTEGER
B INPUT Score
C IF Score >= 50 THEN
D output "Pass"
E ENDIF
Question 2
A Lives ← 3
B WHILE Lives > 0 DO
C Output Lives
D Lives ← Lives - 1
E ENDWHILE
Question 3
A INPUT Mark
B if Mark > 49 THEN
C OUTPUT "Pass"
D ENDIF
Question 4
A INPUT Number
B OUTPUT ← Number * 2
C OUTPUT Result
Question 5
A for Count ← 1 TO 5
B OUTPUT Count
C NEXT Count

Answer Key

Keywords in upper case
Section A: Quick Questions
Q1
B — IF Score > 50 THEN
Q2
B — ENDIF
Q3
A — WHILE Count < 10 DO
Q4
A — ENDWHILE
Q5
A — Total
Section B: Match the Pairs
Q1
IF Score >= 50 THEN OUTPUT "Pass" ENDIF → Correct: the keywords IF, THEN, OUTPUT and ENDIF are all written in upper case
Q2
WHILE Count < 5 DO Count ← Count + 1 ENDWHILE → Correct: WHILE, DO and ENDWHILE are keywords in upper case, while Count is an identifier in Pascal case
Q3
Every keyword in Cambridge pseudocode, including the one that closes a selection, is written in upper case → IF Age >= 16 THEN OUTPUT "Adult" ENDIF
Q4
A keyword can never be used as an identifier name, so a variable must have a different name such as Total → DECLARE Total : INTEGER
Q5
if Score >= 50 THEN OUTPUT "Pass" endif → The keywords if and endif are in lower case. They should be IF and ENDIF.
Q6
DECLARE WHILE : INTEGER → WHILE is a keyword, so it cannot be used as an identifier. Use a name such as Counter instead.
Section C: Definitions
Q1
IF — IF is a pseudocode keyword. All keywords (IF, ENDIF, WHILE, OUTPUT) are written in upper case and never used as identifier names. Lower case, such as if, is a presentation error.
Section D: Fill in the Blanks
Q1
IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Q2
IF Mark >= 50 THEN OUTPUT "Pass" ENDIF
Q3
WHILE Count <= 5 DO Count ← Count + 1 ENDWHILE
Q4
WHILE Count <= 5 DO Count ← Count + 1 ENDWHILE
Q5
IF Age >= 18 THEN OUTPUT "Adult" ENDIF
Section E: Spot the Error
Q1
D — OUTPUT is a keyword, so it must be written in upper case. Lower-case output is a presentation error. The line should be OUTPUT "Pass".
Q2
C — Every letter of a keyword must be upper case. Output with a capital O and lower-case letters is wrong. It should be OUTPUT Lives.
Q3
B — The keyword IF must be in upper case. The lower-case if is a presentation error. It should be IF Mark > 49 THEN.
Q4
B — OUTPUT is a keyword, so it can never be used as an identifier name. The variable needs a different name, such as Result ← Number * 2.
Q5
A — FOR is a keyword and must be written in upper case. The line should be FOR Count ← 1 TO 5.