How does a program manipulate text?
Use common string-handling operations including length, position, substring, concatenation, and converting between case and between strings and numbers.
A focused answer to AQA GCSE Computer Science 3.2.9, covering common string-handling operations such as length, position, substring, concatenation, case conversion and converting between strings and numbers.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
AQA wants you to use common string-handling operations: finding the length, finding the position of a character, extracting a substring, joining strings (concatenation), changing case, and converting between strings and numbers.
Length and position
Substrings
Substrings are how programs pull a useful part out of a longer string, such as extracting the area code from a phone number or the file extension from a filename.
Concatenation
Conversions
Converting types matters because input from a user often arrives as a string and must be turned into a number before arithmetic. Comparing user input ignoring case (for example accepting "YES", "Yes" and "yes") is usually done by converting both sides to the same case first.
Strings and character codes
String handling links closely to character encoding, because each character in a string has an underlying code (such as its ASCII value). This is why you can compare strings alphabetically (the codes are ordered) and why converting case works by shifting the code by 32. Some operations let you get the code of a character or the character for a code, which is useful for tasks such as checking whether a character is a digit or shifting letters in a simple cipher. Remembering that a string is really a sequence of coded characters explains why case-insensitive comparison usually converts both strings to the same case first.
A typical string task
Many programs need to clean or check user input, which is string handling in practice. To validate a username you might check its length is within a range, that it has no spaces (testing each character), and convert it to lower case so "Sam" and "sam" are treated the same before comparing. To build an email address you concatenate the username, an "@" symbol and the domain. To extract a file extension you find the position of the dot and take the substring after it. These everyday tasks combine length, position, substring, concatenation and case conversion, which is exactly the toolkit this dot point covers.
Try this
Q1. State the length of the string "binary". [1 mark]
- Cue. 6, because it has six characters.
Q2. Give the result of concatenating "web" and "site". [1 mark]
- Cue. "website".
Exam-style practice questions
Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AQA 20204 marksA program is given the string name = 'Computer'. State the length of the string, the character at position 0, and the substring of the first three characters. Then write an expression that concatenates name with the string ' Science'.Show worked answer →
Length: 8, because "Computer" has eight characters. Character at position 0 (zero-based): 'C'. First three characters (substring from position 0, length 3): "Com".
Concatenation: name + ' Science', which produces "Computer Science".
Markers reward the correct length (8), the zero-based first character 'C', the substring "Com", and a concatenation that joins the two strings with the space preserved.
AQA 20224 marksA user enters their age as text from the keyboard. Explain why the program must convert this input before it can add 1 to it, and describe the conversion needed. Give the result of '17' converted then increased by 1.Show worked answer →
Keyboard input arrives as a string, so "17" is text, not a number. Adding 1 directly would fail or concatenate, because arithmetic cannot be performed on a string of digits.
The program must convert the string "17" to an integer (a string-to-integer conversion), giving the number 17, which can then have 1 added to give 18. To output it again it may be converted back to a string.
Markers reward the reason (input is a string, not a number), naming the string-to-integer conversion, and the correct result 18.
Related dot points
- Use the common data types, declare and assign variables and constants, and understand the difference between a variable and a constant.
A focused answer to AQA GCSE Computer Science 3.2.1, covering the common data types, declaring and assigning variables and constants, and the difference between a variable and a constant.
- Use arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT, applying correct operator precedence.
A focused answer to AQA GCSE Computer Science 3.2.3 and 3.2.4, covering arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT with operator precedence.
- Use one-dimensional and two-dimensional arrays and records to store collections of data, and access elements using indexes and field names.
A focused answer to AQA GCSE Computer Science 3.2.6, covering one-dimensional and two-dimensional arrays and records, and accessing elements using indexes and field names.
- Understand how characters are represented using ASCII and Unicode character sets, and the effect of the character set on storage and the range of characters.
A focused answer to AQA GCSE Computer Science 3.3.5, covering how characters are represented using ASCII and Unicode, and the effect of the character set on storage and the range of characters.
Sources & how we know this
- AQA GCSE Computer Science (8525) specification — AQA (2020)