Layout conventions for Cambridge pseudocode

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

Layout conventions for Cambridge pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line follows the Cambridge convention for keywords and identifiers?
A declare totalscore : integer
B DECLARE TotalScore : INTEGER
2. Which line writes the keyword OUTPUT correctly?
A OUTPUT "Hello"
B output "Hello"
3. Which identifier follows the mixed case (PascalCase) convention?
A playername
B PlayerName
4. How many spaces should lines inside a statement, such as a loop body, be indented by?
A Four spaces
B One space
5. Which constant declaration follows the layout convention?
A CONSTANT MaxScore ← 100
B constant maxscore ← 100

Match the Pairs

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

Left columnRight column
1DECLARE TotalScore : INTEGER AA meta-variable in angled brackets that stands for any identifier you choose to write
2<identifier> BThe keywords DECLARE and INTEGER are written in lower case. They must be in upper case, and the identifier should be PascalCase: DECLARE TotalScore : INTEGER
3Keywords such as CONSTANT are written in upper case and identifiers use PascalCase CThe lines inside the IF statement are not indented. THEN and OUTPUT should be indented by four spaces.
4Lines inside a statement are indented by four spaces DIF Score > 50 THEN OUTPUT "Pass" ENDIF
5declare totalscore : integer ECONSTANT MaxScore ← 100
6IF Age >= 16 THEN OUTPUT "Adult" ENDIF FA keyword in upper case followed by an identifier in PascalCase, the standard layout for declaring a variable

Definitions

DECLARE TotalScore : INTEGER

Fill in the Blanks

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

1.
_______ TotalScore : INTEGER
2.
________ MaxScore ← 100
3.
_____ PlayerName
4.
IF Score > 50 THEN ______ "Pass" ENDIF
5.
DECLARE ____________ : <data type>

Spot the Error

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

Question 1
A declare Score : INTEGER
B Score ← 0
C OUTPUT Score
Question 2
A DECLARE Name : STRING
B input Name
C OUTPUT Name
Question 3
A FOR Count ← 1 TO 5
B OUTPUT Count
C Total ← Total + Count
D Next Count
Question 4
A CONSTANT MaxScore ← 100
B DECLARE total_score : INTEGER
C TotalScore ← 0
Question 5
A // Layout of INPUT and OUTPUT
B OUTPUT <value>
C INPUT [identifier]

Answer Key

Layout conventions for Cambridge pseudocode
Section A: Quick Questions
Q1
B — DECLARE TotalScore : INTEGER
Q2
A — OUTPUT "Hello"
Q3
B — PlayerName
Q4
A — Four spaces
Q5
A — CONSTANT MaxScore ← 100
Section B: Match the Pairs
Q1
DECLARE TotalScore : INTEGER → A keyword in upper case followed by an identifier in PascalCase, the standard layout for declaring a variable
Q2
<identifier> → A meta-variable in angled brackets that stands for any identifier you choose to write
Q3
Keywords such as CONSTANT are written in upper case and identifiers use PascalCase → CONSTANT MaxScore ← 100
Q4
Lines inside a statement are indented by four spaces → IF Score > 50 THEN OUTPUT "Pass" ENDIF
Q5
declare totalscore : integer → The keywords DECLARE and INTEGER are written in lower case. They must be in upper case, and the identifier should be PascalCase: DECLARE TotalScore : INTEGER
Q6
IF Age >= 16 THEN OUTPUT "Adult" ENDIF → The lines inside the IF statement are not indented. THEN and OUTPUT should be indented by four spaces.
Section C: Definitions
Q1
DECLARE TotalScore : INTEGER — Pseudocode layout convention: keywords in UPPER CASE, identifiers in PascalCase, and lines inside a statement indented four spaces. Meta-variables use angled brackets, like <identifier>.
Section D: Fill in the Blanks
Q1
DECLARE TotalScore : INTEGER
Q2
CONSTANT MaxScore ← 100
Q3
INPUT PlayerName
Q4
IF Score > 50 THEN OUTPUT "Pass" ENDIF
Q5
DECLARE <identifier> : <data type>
Section E: Spot the Error
Q1
A — Keywords such as DECLARE are always written in UPPER CASE. The line should be DECLARE Score : INTEGER.
Q2
B — INPUT is a keyword, so it must be in UPPER CASE. The line should be INPUT Name.
Q3
D — NEXT is a keyword, so it must be written fully in UPPER CASE, not mixed case. The line should be NEXT Count.
Q4
B — Cambridge identifiers use PascalCase, with no underscores or lower-case first letter. It should be DECLARE TotalScore : INTEGER.
Q5
C — Meta-variables in Cambridge pseudocode are written in angled brackets <like this>, not square brackets. It should be INPUT <identifier>.