SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
AQA 8525 · Section 3.2 · 3.2.3

String
Handling

LEN · SUBSTRING · UPPER · LOWER · Concatenation

CSZoneAQA GCSE Computer Science 8525
String Functions — AQA 8525

Built-in String Operations

FunctionWhat it doesExample → Result
LEN(str)Returns the length (number of characters)LEN('Hello') → 5
SUBSTRING(str, start, len)Extracts characters from position start, length lenSUBSTRING('Hello',1,3) → 'ell'
UPPER(str)Converts all characters to uppercaseUPPER('hello') → 'HELLO'
LOWER(str)Converts all characters to lowercaseLOWER('HELLO') → 'hello'
⚡ AQA SUBSTRING:Starts at position 1 (not 0) in AQA pseudocode!
String Examples

Worked Examples

word ← 'Computer'

OUTPUT LEN(word)
                    ← 8

OUTPUT SUBSTRING(word, 1, 4)
                    ← 'Comp'

OUTPUT UPPER(word)
                    ← 'COMPUTER'

first ← SUBSTRING(word, 1, 1)
                    ← 'C'
Concatenation

Joining Strings Together

first ← 'Ahmed'
last ← 'Khan'
full ← first + ' ' + last
OUTPUT full
                ← 'Ahmed Khan'

score ← 85
msg ← 'Your score is ' + STR(score)
OUTPUT msg
                ← 'Your score is 85'
Remember:You can only concatenate strings. Use STR() to convert numbers before joining.
Exam Practice

Have a go at this question

AQA-style question
A string called email stores 'user@school.ac.uk'. Write pseudocode to:
(a) Output the length of the string
(b) Output the first 4 characters
(c) Output the string in uppercase
3 marks
email ← 'user@school.ac.uk'
(a) OUTPUT LEN(email) ← 17
(b) OUTPUT SUBSTRING(email, 1, 4) ← 'user'
(c) OUTPUT UPPER(email) ← 'USER@SCHOOL.AC.UK'
Key Takeaways

What to Remember

LEN(str) — number of characters · UPPER/LOWER — change case
SUBSTRING(str, start, length) — starts at position 1 in AQA!
Concatenate strings with +: 'Hello' + ' ' + name
Convert numbers with STR() before concatenating: STR(score)