Keywords in capital letters

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

Keywords in capital letters

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 loop header uses keywords correctly?
A for Count ← 1 to 10
B FOR Count ← 1 TO 10
3. Which statement about keywords is true?
A Keywords can be written in any mix of upper and lower case
B Keywords such as OUTPUT are written in upper case
4. Which statement correctly ends an IF structure?
A ENDIF
B endif
5. Which identifier name is allowed?
A TotalScore
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 ANEXT is a keyword, so it cannot be used as an identifier name. Use a name such as NextNumber.
2FOR Count ← 1 TO 10 BFOR Count ← 1 TO 5 OUTPUT Count NEXT Count
3An IF statement must be closed with its keyword ENDIF in capital letters CIF and THEN are keywords, so they are written in capital letters
4A FOR loop is closed with the keyword NEXT in capital letters DIF Age >= 16 THEN OUTPUT "Allowed" ENDIF
5if Score > 50 then EFOR and TO are keywords in capitals, and the loop is closed later by NEXT
6DECLARE NEXT : INTEGER FThe keywords if and then are in lower case. They must be IF and THEN.

Definitions

IF

Fill in the Blanks

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

1.
IF Score >= 50 THEN OUTPUT "Pass" _____
2.
FOR Count ← 1 TO 5 OUTPUT Count ____ Count
3.
IF Age >= 16 ____ OUTPUT "Allowed" ENDIF
4.
___ Index ← 1 TO 10 OUTPUT Index * 2 NEXT Index
5.
_____ Guess IF Guess = 7 THEN OUTPUT "Correct"

Spot the Error

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

Question 1
A INPUT Score
B IF Score >= 50 THEN
C output "Pass"
D ENDIF
Question 2
A Total ← 0
B FOR Count ← 1 TO 5
C Total ← Total + Count
D next Count
Question 3
A DECLARE Name : STRING
B DECLARE Age : INTEGER
C DECLARE NEXT : INTEGER
D Total ← 0
Question 4
A INPUT Mark
B if Mark > 90 THEN
C OUTPUT "Top grade"
D ENDIF
Question 5
A Total ← 0
B FOR Num ← 1 to 3
C OUTPUT Num
D NEXT Num

Answer Key

Keywords in capital letters
Section A: Quick Questions
Q1
A — IF Score > 50 THEN
Q2
B — FOR Count ← 1 TO 10
Q3
B — Keywords such as OUTPUT are written in upper case
Q4
A — ENDIF
Q5
A — TotalScore
Section B: Match the Pairs
Q1
IF Score > 50 THEN → IF and THEN are keywords, so they are written in capital letters
Q2
FOR Count ← 1 TO 10 → FOR and TO are keywords in capitals, and the loop is closed later by NEXT
Q3
An IF statement must be closed with its keyword ENDIF in capital letters → IF Age >= 16 THEN OUTPUT "Allowed" ENDIF
Q4
A FOR loop is closed with the keyword NEXT in capital letters → FOR Count ← 1 TO 5 OUTPUT Count NEXT Count
Q5
if Score > 50 then → The keywords if and then are in lower case. They must be IF and THEN.
Q6
DECLARE NEXT : INTEGER → NEXT is a keyword, so it cannot be used as an identifier name. Use a name such as NextNumber.
Section C: Definitions
Q1
IF — A Cambridge pseudocode keyword. All keywords, such as IF, THEN, FOR, NEXT and OUTPUT, are written in capital letters, and they cannot be used as identifier names.
Section D: Fill in the Blanks
Q1
IF Score >= 50 THEN OUTPUT "Pass" ENDIF
Q2
FOR Count ← 1 TO 5 OUTPUT Count NEXT Count
Q3
IF Age >= 16 THEN OUTPUT "Allowed" ENDIF
Q4
FOR Index ← 1 TO 10 OUTPUT Index * 2 NEXT Index
Q5
INPUT Guess IF Guess = 7 THEN OUTPUT "Correct"
Section E: Spot the Error
Q1
C — OUTPUT is a Cambridge pseudocode keyword, so it must be written in capital letters. The line should be OUTPUT "Pass".
Q2
D — NEXT closes a FOR loop and is a keyword, so it must be in capital letters. The line should be NEXT Count.
Q3
C — NEXT is a keyword, so it cannot be used as an identifier name. Use a name such as Total instead.
Q4
B — IF is a keyword and must be written in capital letters. The line should be IF Mark > 90 THEN.
Q5
B — TO is a keyword in a FOR loop and must be in capital letters. The line should be FOR Num ← 1 TO 3.