This topic summary covers Knowledge Organiser: String Handling within String Handling for GCSE Computer Science. Revise String Handling in 3.2 Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This is a high-frequency topic, so it is worth revising until the explanation feels precise and repeatable. It is section 7 of 7 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Knowledge Organiser: String Handling
Key Terms
- String: A sequence of characters stored as text
- Concatenation: Joining two strings together using + (e.g. "Hello" + " " + "World")
- Substring: Extracting part of a string using
string.substring(start, length) - Length: The number of characters in a string, accessed with
string.length - ASC: Converts a character to its ASCII code number (e.g. ASC("A") = 65)
- CHR: Converts an ASCII code number to a character (e.g. CHR(65) = "A")
Must-Know Facts
- Strings are 0-indexed: the first character is at position 0
substring(start, length)takes a starting position and a number of characters, NOT an end position- String operations return a new string — the original is not changed
.upperand.lowerconvert case for comparison purposes- ASC("A") = 65, ASC("a") = 97 — upper and lower case have different codes
Key Concepts
- Get length:
"Hello".lengthreturns 5 - Extract chars:
"Hello".substring(0, 2)returns "He" - Convert case:
"Hello".upperreturns "HELLO" - Join strings:
"First" + " " + "Last"returns "First Last" - ASCII:
ASC("A")= 65;CHR(65)= "A"
Common Mistakes
- Using 1-based indexing instead of 0-based: Strings are 0-indexed in most pseudocode — the first character is at position 0, not 1
- Confusing substring's second argument:
substring(start, length)takes a LENGTH (number of characters), not an end position —substring(2, 3)gets 3 characters from position 2 - Forgetting case when comparing strings: "Hello" does not equal "hello" — use
.upperor.lowerto standardise case before comparison - Confusing ASC and CHR: ASC converts a character TO its ASCII number; CHR converts an ASCII number TO a character — they work in opposite directions
- Trying to add a number directly to a string: Concatenation joins strings — a number must be converted to a string first before joining with
+
Practice questions for String Handling
The string variable word = "Hello". What does word.length return?
Explain the purpose of the ASC() and CHR() functions in OCR pseudocode. Give one reason a programmer might need to convert between characters and their ASCII codes.