SLIDE 1 / 10
CSZone.co.uk
Click anywhere to advance · Arrow keys also work
AQA 7517 · Paper 1 · 4.1.1e

String
Handling

AQA A-Level Computer Science · Section 4.1 Fundamentals of Programming

WHAT YOU'LL LEARN
LEN · SUBSTRING · UPPER/LOWER · CHAR · ASC · Concatenation
AQA SPEC LINK
4.1.1 — Use of string-handling functions in programs
Strings in AQA

What is a String?

A string is an ordered sequence of characters enclosed in double quotes. Strings are indexed from position 0 (zero-indexed) or position 1 — AQA accepts either but be consistent.
AQA INDEXING EXAMPLE
word ← "Python"
— Index 0: 'P', Index 1: 'y', Index 2: 't', Index 3: 'h', Index 4: 'o', Index 5: 'n'
LEN

LEN() — String Length

SYNTAX & EXAMPLES
LEN("Hello") → 5
LEN("") → 0
name ← "Computer Science"
OUTPUT LEN(name) → 16
LEN() counts every character including spaces. Python equivalent: len(string). Useful for validation loops and iterating through characters.
SUBSTRING

SUBSTRING() — Extracting Part of a String

AQA SYNTAX
SUBSTRING(string, start, length)

SUBSTRING("Hello World", 0, 5) → "Hello"
SUBSTRING("Hello World", 6, 5) → "World"
⚠️ AQA NOTE
Parameters are: position (0-indexed), start position, number of characters. Python uses slicing: s[0:5] instead.
UPPER & LOWER

Case Conversion

UPPER()
UPPER("hello") → "HELLO"
UPPER("Python") → "PYTHON"
Python: "hello".upper()
LOWER()
LOWER("HELLO") → "hello"
LOWER("Python") → "python"
Python: "HELLO".lower()
Used for case-insensitive comparisons: IF UPPER(response) = "YES" THEN
CHAR & ASC

Character ↔ ASCII Conversion

ASC() — Char to Code
ASC('A') → 65
ASC('a') → 97
ASC('0') → 48
Python: ord('A')
CHAR() — Code to Char
CHAR(65) → 'A'
CHAR(97) → 'a'
CHAR(48) → '0'
Python: chr(65)
Key values: A=65, Z=90, a=97, z=122, 0=48, 9=57. Used in encryption and character manipulation.
Concatenation

Joining Strings with +

EXAMPLES
first ← "Alice"
last ← "Smith"
full ← first + " " + last → "Alice Smith"
OUTPUT "Score: " + STR(95) → "Score: 95"
⚠️ You can only concatenate string + string. Convert numbers first with STR(). In Python, f-strings (f"Hello {name}") are often cleaner.
String Iteration

Looping Through Characters

COUNT VOWELS EXAMPLE
word ← USERINPUT
count ← 0
FOR i ← 0 TO LEN(word) - 1
  letter ← SUBSTRING(word, i, 1)
  IF letter = "a" OR letter = "e" OR letter = "i" OR letter = "o" OR letter = "u" THEN
    count ← count + 1
  ENDIF
ENDFOR
OUTPUT count
AQA Exam Style

Practice Question

AQA 7517 — Paper 1 Style
What is the output of the following pseudocode?

s ← "AQA Computer Science"
OUTPUT LEN(s)
OUTPUT SUBSTRING(s, 4, 8)
OUTPUT UPPER(SUBSTRING(s, 0, 3))
[3 marks]
1 mark
LEN("AQA Computer Science") → 20
1 mark
SUBSTRING(s, 4, 8) → "Computer"
1 mark
UPPER(SUBSTRING(s, 0, 3)) → "AQA"
Summary

String Functions Reference

FunctionPurposePython Equivalent
LEN(s)Length of stringlen(s)
SUBSTRING(s,i,n)Extract n chars from index is[i:i+n]
UPPER(s)Convert to uppercases.upper()
LOWER(s)Convert to lowercases.lower()
ASC(c)Character to ASCII codeord(c)
CHAR(n)ASCII code to characterchr(n)
🎉 Lesson complete — move to the quiz!