← IGCSE Computer Science Paper 2

First character at position zero or one

Position 1 is the first character in Cambridge pseudocode, so this returns the first letter. Some languages count from 0 instead, so state which numbering you use.

Understanding First character at position zero or one in IGCSE Computer Science Paper 2

What it does: Start 1 means the first character, and length 3 takes three characters, giving the first three letters. Position 2 is the second character with one-based numbering ('A'), but under zero-based numbering it is the third character ('T'), so the numbering must be stated. Cambridge pseudocode generally counts from 1. Some programming languages count from 0, but that is not the syllabus default. P is 1, y is 2, t is 3, h is 4. Starting at position 2 and taking 3 characters gives yth. The result depends on the numbering rule, so stating it makes your answer clear and shows your reasoning.

Common mistakes: Cambridge pseudocode numbers the first character as position 1, so position 0 does not exist. The start position should be 1 to get the first letter. Position 2 is the second character, so this would output y, not P. To get the first letter the start position must be 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 337–346) and word search (Modules 337–357).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
In Cambridge pseudocode, what does SUBSTRING("Computer", 1, 1) return?
"o" (position 1 is the second character)"C" (position 1 is the first character)
Matches
FirstLetter ← SUBSTRING(Name, 0, 1)
↓
Starting at 0 is wrong in Cambridge pseudocode, where the first character is position 1. The start should be 1.
Applying
Meanings
Term
SUBSTRING(Word, 1, 1)
Meaning
Position 1 is the first character in Cambridge pseudocode, so this returns the first letter. Some languages count from 0 instead, so state which numbering you use.
Practice
Word ← "Planet"
Testing
Gaps
First ← SUBSTRING(Word, , 1)
Check Answer
Spots
3Word ← "Cambridge"
4First ← SUBSTRING(Word, 0, 1)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Constellation Wolf' badge — Space Legend, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. In Cambridge pseudocode, what does SUBSTRING("Computer", 1, 1) return?
A. "C" (position 1 is the first character) ✓
B. "o" (position 1 is the second character)
The Cambridge syllabus numbers characters from 1, so a start position of 1 gives the first letter.
2. Which statement matches the syllabus examples for SUBSTRING?
A. The first character of a string is at position 1 ✓
B. The first character of a string is at position 0
Cambridge pseudocode generally counts from 1. Some programming languages count from 0, but that is not the syllabus default.
3. Counting from 1, what does SUBSTRING("Python", 2, 3) return?
A. "yth" ✓
B. "tho"
P is 1, y is 2, t is 3, h is 4. Starting at position 2 and taking 3 characters gives yth.
4. A language counts positions from 0. What does the same call, SUBSTRING("Python", 2, 3), return there?
A. "yth"
B. "tho" ✓
With 0 numbering, P is 0, y is 1, t is 2, h is 3, o is 4. Starting at 2 for 3 characters gives tho. The same call gives a different result under each rule.
5. Which call gets the first letter of Word in Cambridge pseudocode?
A. SUBSTRING(Word, 0, 1)
B. SUBSTRING(Word, 1, 1) ✓
Position 1 is the first character in Cambridge pseudocode. Position 0 is used only in languages that count from 0.

Match the Pairs

SUBSTRING(Word, 1, 1) → Returns the first character of Word, because Cambridge pseudocode numbers the first character as position 1
Word[0] → Gets the first character in a language that counts positions from 0, such as Python
With one-based numbering, the first three letters of Word start at position 1 → SUBSTRING(Word, 1, 3)
The same call returns different characters under each numbering rule. With Word ← "CAT", this call gives "C" if counting from 1 but "A" if counting from 0 → SUBSTRING(Word, 2, 1)
FirstLetter ← SUBSTRING(Name, 0, 1) → Starting at 0 is wrong in Cambridge pseudocode, where the first character is position 1. The start should be 1.
// Takes the 2nd letter: SUBSTRING(Word, 2, 1) with no numbering stated → The answer does not state whether positions start at 0 or 1, so the result is ambiguous. State the numbering used in an exam answer.

Key Term

SUBSTRING(Word, 1, 1)
Position 1 is the first character in Cambridge pseudocode, so this returns the first letter. Some languages count from 0 instead, so state which numbering you use.

Fill in the Blanks

1. First ← SUBSTRING(Word, 1, 1)
Hint: Type the start position that Cambridge pseudocode gives to the first character.
2. Word ← "CODE" OUTPUT SUBSTRING(Word, 1, 2)
Hint: Type the string function that extracts part of a string, here the first two letters.
3. Word ← "CODE" Second ← SUBSTRING(Word, 2, 1)
Hint: Type the start position of the second character, counting the Cambridge way.
4. Word ← "CODE" Last ← SUBSTRING(Word, 4, 1)
Hint: Type the start position of the final letter in a four-letter word, counting from the syllabus start number.
5. // Python counts from 0, Cambridge from 1
Hint: Type the position number that some languages give to the first character.

Spot the Error

Question 1
A DECLARE Word : STRING
B DECLARE First : CHAR
C Word ← "Cambridge"
D First ← SUBSTRING(Word, 0, 1)
E OUTPUT First
Line D — Cambridge pseudocode numbers the first character as position 1, so position 0 does not exist. The start position should be 1 to get the first letter.
Question 2
A Word ← "Python"
B Letter ← SUBSTRING(Word, 2, 1)
C OUTPUT Letter
D // outputs P
Line B — Position 2 is the second character, so this would output y, not P. To get the first letter the start position must be 1.
Question 3
A Name ← "Zoe"
B Initial ← SUBSTRING(1, Name, 1)
C OUTPUT Initial
Line B — The arguments are in the wrong order. SUBSTRING takes the string first, then the start position (1 for the first character), then the length.
Question 4
A // 0 is the first character
B Word ← "Hello"
C Second ← SUBSTRING(Word, 2, 1)
D OUTPUT Second
Line A — The comment states the wrong numbering. In Cambridge pseudocode the first character is position 1, which is why position 2 gives the second letter, e.
Question 5
A Word ← "Dog"
B Last ← SUBSTRING(Word, 2, 1)
C OUTPUT Last
D // outputs g
Line B — Counting from 0, position 2 would be the last letter, but Cambridge pseudocode counts from 1. Dog has 3 characters, so the last one is at position 3. Position 2 gives o.

Student with a class code? Join your class →