Identifier rules in Cambridge pseudocode

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

Identifier rules in Cambridge pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which identifier follows the Cambridge pseudocode rules?
A first_name
B FirstName
2. Which identifier is valid?
A TotalScore
B Total Score
3. Which identifier is valid?
A 1Player
B Player1
4. Which identifier is valid?
A Price
B Price$
5. Which identifier is valid?
A Cafe
B Café

Match the Pairs

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

Left columnRight column
1FirstName AA valid identifier that uses a digit after the first character
2Score2 BThe identifier contains an underscore. Only letters and digits are allowed, so it should be FirstName.
3An identifier must not contain spaces or underscores, so join the words together in PascalCase CCONSTANT PassMark ← 50
4An identifier can be the name of a constant as well as a variable, and it still follows the PascalCase rules DDECLARE TotalScore : INTEGER
5DECLARE first_name : STRING EThe identifier starts with a digit. An identifier must start with a capital letter, so it should be SecondScore.
6DECLARE 2ndScore : INTEGER FA valid identifier: PascalCase, letters only, starts with a capital letter

Definitions

identifier

Fill in the Blanks

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

1.
DECLARE FirstName : STRING FirstName ← "Ava" OUTPUT _________
2.
_______ TotalScore : INTEGER TotalScore ← 0 OUTPUT TotalScore
3.
DECLARE Score2 : INTEGER Score2 ← 10 OUTPUT ______
4.
CONSTANT MaxScore ← 100 OUTPUT "Top mark:" OUTPUT ________
5.
DECLARE TotalCost : REAL TotalCost ← 9.5 ______ TotalCost

Spot the Error

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

Question 1
A DECLARE FirstName : STRING
B DECLARE Age : INTEGER
C INPUT First Name
D OUTPUT FirstName
Question 2
A DECLARE Score : INTEGER
B DECLARE Total_Score : INTEGER
C TotalScore ← Score * 2
Question 3
A DECLARE 1stPlayer : STRING
B INPUT FirstPlayer
C OUTPUT FirstPlayer
Question 4
A DECLARE Price : REAL
B DECLARE Quantity : INTEGER
C INPUT Quantity
D Price ← Quantité * 2.5
Question 5
A CONSTANT MaxMark ← 100
B DECLARE Mark : INTEGER
C INPUT Mark$
D OUTPUT Mark, MaxMark

Answer Key

Identifier rules in Cambridge pseudocode
Section A: Quick Questions
Q1
B — FirstName
Q2
A — TotalScore
Q3
B — Player1
Q4
A — Price
Q5
A — Cafe
Section B: Match the Pairs
Q1
FirstName → A valid identifier: PascalCase, letters only, starts with a capital letter
Q2
Score2 → A valid identifier that uses a digit after the first character
Q3
An identifier must not contain spaces or underscores, so join the words together in PascalCase → DECLARE TotalScore : INTEGER
Q4
An identifier can be the name of a constant as well as a variable, and it still follows the PascalCase rules → CONSTANT PassMark ← 50
Q5
DECLARE first_name : STRING → The identifier contains an underscore. Only letters and digits are allowed, so it should be FirstName.
Q6
DECLARE 2ndScore : INTEGER → The identifier starts with a digit. An identifier must start with a capital letter, so it should be SecondScore.
Section C: Definitions
Q1
identifier — The name of a variable, constant, procedure or function. Use PascalCase: letters and digits only, no spaces or underscores, start with a capital letter, e.g. FirstName.
Section D: Fill in the Blanks
Q1
DECLARE FirstName : STRING FirstName ← "Ava" OUTPUT FirstName
Q2
DECLARE TotalScore : INTEGER TotalScore ← 0 OUTPUT TotalScore
Q3
DECLARE Score2 : INTEGER Score2 ← 10 OUTPUT Score2
Q4
CONSTANT MaxScore ← 100 OUTPUT "Top mark:" OUTPUT MaxScore
Q5
DECLARE TotalCost : REAL TotalCost ← 9.5 OUTPUT TotalCost
Section E: Spot the Error
Q1
C — An identifier cannot contain spaces, so 'First Name' is read as two separate words. It should be INPUT FirstName.
Q2
B — Identifiers may only use letters and digits, so underscores are not allowed. Use PascalCase: DECLARE TotalScore : INTEGER.
Q3
A — An identifier cannot start with a digit. It must start with a letter, so the line should be DECLARE FirstPlayer : STRING.
Q4
D — Identifiers cannot contain accented letters such as é. Only the plain letters A-Z and digits are allowed, so it should be Quantity.
Q5
C — Symbols such as $ cannot be used in identifiers. Only letters and digits are allowed, so it should be INPUT Mark.