Identifiers in Pascal case (7a)

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

Identifiers in Pascal case (7a)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which identifier follows Cambridge Pascal case?
A number_of_players
B NumberOfPlayers
2. Which identifier is written correctly?
A TotalScore
B Total Score
3. Which identifier is NOT allowed?
A Place1
B 1stPlace
4. Which identifier is the better, more meaningful name for storing a student's age?
A StudentAge
B X
5. In Cambridge pseudocode, Countdown and CountDown refer to...
A The same variable
B Two different variables

Match the Pairs

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

Left columnRight column
1NumberOfPlayers AThe identifier starts with a digit. It must start with a letter, for example SecondPlayer.
2Score2 BA good identifier in Pascal case: a capital letter starts each word and there are no spaces or underscores
3An identifier must not contain spaces or underscores, so each word is joined and starts with a capital letter CCountdown and CountDown
4Identifiers are not case sensitive, so these two names refer to the same variable DA valid identifier that uses a digit, which is allowed because it does not come first
5DECLARE 2ndPlayer : STRING EThe identifier uses underscores and no capital letters. Pascal case would be NumberOfPlayers.
6DECLARE number_of_players : INTEGER FTotalScore

Definitions

NumberOfPlayers

Fill in the Blanks

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

1.
// Stores how many people are playing DECLARE _______________ : INTEGER
2.
DECLARE Score : INTEGER Score ← 0 _____ ← Score + 1
3.
_______ HighScore : INTEGER
4.
DECLARE FirstName : STRING OUTPUT "Enter your first name" INPUT _________
5.
// Is the game finished? DECLARE GameOver : _______

Spot the Error

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

Question 1
A DECLARE PlayerName : STRING
B DECLARE PlayerScore : INTEGER
C DECLARE High_Score : INTEGER
D OUTPUT PlayerName
Question 2
A DECLARE TotalMarks : INTEGER
B TotalMarks ← 0
C Total Marks ← TotalMarks + 5
D OUTPUT TotalMarks
Question 3
A DECLARE FirstScore : INTEGER
B DECLARE 2ndScore : INTEGER
C INPUT FirstScore
D INPUT SecondScore
Question 4
A DECLARE PlayerAge : INTEGER
B DECLARE favColour : STRING
C INPUT PlayerAge
D INPUT FavColour
Question 5
A DECLARE Price : REAL
B DECLARE Quantity : INTEGER
C DECLARE x : REAL
D TotalCost ← Price * Quantity

Answer Key

Identifiers in Pascal case (7a)
Section A: Quick Questions
Q1
B — NumberOfPlayers
Q2
A — TotalScore
Q3
B — 1stPlace
Q4
A — StudentAge
Q5
A — The same variable
Section B: Match the Pairs
Q1
NumberOfPlayers → A good identifier in Pascal case: a capital letter starts each word and there are no spaces or underscores
Q2
Score2 → A valid identifier that uses a digit, which is allowed because it does not come first
Q3
An identifier must not contain spaces or underscores, so each word is joined and starts with a capital letter → TotalScore
Q4
Identifiers are not case sensitive, so these two names refer to the same variable → Countdown and CountDown
Q5
DECLARE 2ndPlayer : STRING → The identifier starts with a digit. It must start with a letter, for example SecondPlayer.
Q6
DECLARE number_of_players : INTEGER → The identifier uses underscores and no capital letters. Pascal case would be NumberOfPlayers.
Section C: Definitions
Q1
NumberOfPlayers — An identifier: a variable name in Pascal case. Capital letter starts each word, letters and digits only, no spaces or underscores, can't start with a digit. Not case sensitive.
Section D: Fill in the Blanks
Q1
// Stores how many people are playing DECLARE NumberOfPlayers : INTEGER
Q2
DECLARE Score : INTEGER Score ← 0 Score ← Score + 1
Q3
DECLARE HighScore : INTEGER
Q4
DECLARE FirstName : STRING OUTPUT "Enter your first name" INPUT FirstName
Q5
// Is the game finished? DECLARE GameOver : BOOLEAN
Section E: Spot the Error
Q1
C — Identifiers must not contain underscores. In Pascal case the words are joined and each starts with a capital letter, so it should be HighScore.
Q2
C — An identifier cannot contain a space. 'Total Marks' would be read as two separate names. It should be TotalMarks.
Q3
B — An identifier cannot start with a digit. Spell the number as a word, for example SecondScore.
Q4
B — Pascal case starts every word with a capital letter, including the first. It should be FavColour, not favColour.
Q5
C — Identifiers should be meaningful. The single letter x does not say what the variable stores. It should be TotalCost, which matches the calculation on the next line.