📁 Paper 1 · 3.2 Programming
3.2.3 String Handling
AQA 8525 · GCSE Computer Science · ~10 min read
Notes
──
Video
──
Worksheet
──
Quiz

String Operations in AQA

Strings can be manipulated using built-in functions. AQA specifies the following string operations:

FunctionDescriptionExampleResult
LEN(s)Length of string sLEN("Hello")5
SUBSTRING(s, start, len)Extract part of stringSUBSTRING("Hello",0,3)"Hel"
UPPER(s)Convert to uppercaseUPPER("hello")"HELLO"
LOWER(s)Convert to lowercaseLOWER("HELLO")"hello"
+Concatenation (join strings)"Hello" + " " + "World""Hello World"

LEN — String Length

word ← "Computer" OUTPUT LEN(word) // 8 // Useful for checking password length: password ← INPUT() IF LEN(password) < 8 THEN OUTPUT "Too short" ENDIF

SUBSTRING — Extract Part of a String

SUBSTRING(s, start, length) — returns length characters starting from position start (zero-indexed).

text ← "Hello World" OUTPUT SUBSTRING(text, 0, 5) // "Hello" OUTPUT SUBSTRING(text, 6, 5) // "World" OUTPUT SUBSTRING(text, 0, 1) // "H" (first character) // Last character: OUTPUT SUBSTRING(text, LEN(text)-1, 1) // "d"

UPPER and LOWER

Used to standardise string comparison — so "YES", "Yes" and "yes" all match:

answer ← INPUT("Continue? ") IF UPPER(answer) == "YES" THEN OUTPUT "Continuing..." ENDIF

Concatenation with +

firstName ← "Alice" lastName ← "Smith" fullName ← firstName + " " + lastName OUTPUT fullName // "Alice Smith" // Mix number and string — must cast number first: age ← 16 OUTPUT "I am " + str(age) + " years old"

String Indexing (Characters)

Individual characters can be accessed using SUBSTRING with length 1. Strings are zero-indexed like arrays.

s ← "GCSE" OUTPUT SUBSTRING(s, 0, 1) // "G" OUTPUT SUBSTRING(s, 3, 1) // "E"
Exam tip: SUBSTRING is zero-indexed in AQA — position 0 is the first character. The second parameter is the starting position; the third is the length (not end position). Many students confuse end position with length.
⚠️ Common Mistakes
  • SUBSTRING("Hello", 1, 3) = "ell" not "Hel" — position 1 starts at 'e', not 'H'
  • Confusing the third parameter as an end index — it's the LENGTH
  • Forgetting to cast numbers to strings before concatenation
  • UPPER/LOWER returns a new string — it doesn't modify the original
Video coming soon

Key points

  • LEN() counts characters in a string
  • SUBSTRING(s, start, length) — zero-indexed, length not end position
  • UPPER/LOWER for case-insensitive comparison
  • String concatenation with +
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.2.3 String Handling

8 questions · 20 marks

Q1What does LEN("Computer Science") return?[1]
✅ Mark scheme
Mark scheme
16 [1] — count all characters including the space.
Q2What does SUBSTRING("Programming", 0, 4) return?[1]
✅ Mark scheme
Mark scheme
"Prog" [1] — starts at index 0, length 4 characters.
Q3State what SUBSTRING("Hello World", 6, 5) returns. Show your reasoning.[2]
✅ Mark scheme
Mark scheme
"World" [1]; starting position 6 = 'W', taking 5 characters gives 'W','o','r','l','d' [1].
Q4Write pseudo-code to ask for a user's first name and last name, then output "Hello [FirstName] [LastName]!" using string concatenation.[3]
✅ Mark scheme
Mark scheme
firstName ← INPUT() [1]; lastName ← INPUT() [1]; OUTPUT "Hello " + firstName + " " + lastName + "!" [1].
Q5Explain why UPPER() is useful when checking user input against a known string.[2]
✅ Mark scheme
Mark scheme
Users may type in different cases (e.g. "yes", "Yes", "YES") [1]; UPPER() standardises to one case so all valid responses match [1].
Q6Write pseudo-code to extract and output the first character and last character of a string s entered by the user.[4]
✅ Mark scheme
Mark scheme
s ← INPUT() [1]; OUTPUT SUBSTRING(s, 0, 1) for first [1]; OUTPUT SUBSTRING(s, LEN(s)-1, 1) for last [2].
Q7name ← "Alice". What does OUTPUT "Name: " + name + " (len=" + str(LEN(name)) + ")" produce?[2]
✅ Mark scheme
Mark scheme
"Name: Alice (len=5)" [2] — one mark if only one error.
Q8Write pseudo-code using a loop to check each character of a string and count how many are the letter 'a'.[5]
✅ Mark scheme
Mark scheme
s ← INPUT() [1]; count ← 0 [1]; FOR i ← 0 TO LEN(s)-1 [1]; IF SUBSTRING(s,i,1) == "a" THEN count ← count+1 [1]; ENDFOR; OUTPUT count [1].
Check your answers above.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 5
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.2.3 String Handling

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.2.2d Arrays
14 of 57 · AQA 8525
3.2.4/5 Relational & Boolean →