AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Convert character to character code
Full specification wording
String handling operations in a programming language: convert character to character code
Converting a character to its character code means finding the integer that the computer uses to represent that single character.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 5 of 11
Study notes
From the checked teaching notes for this specification point.
The idea
Converting a character to its character code means finding the integer that the computer uses to represent that single character. Every character stored by a computer is encoded as a number, for example using ASCII or Unicode. In many languages a built-in function returns this number: in Python, ord('A') returns 65, and ord('a') returns 97. The reverse operation, turning a code back into a character, uses a different function such as chr(). To answer a question on this, identify the single character being converted, recall or apply the encoding rule, and give the resulting integer code. Remember that upper-case and lower-case letters have different codes, and that digits such as '7' have their own codes distinct from the number 7. The operation works on one character at a time, so converting a whole string means converting each character in turn.
What earns the marks
- States that converting a character to a character code returns the integer used by the computer's character encoding to represent that character.
- Identifies the correct code for a given character, for example that 'A' is 65 in ASCII.
- Recognises that upper-case and lower-case versions of the same letter have different codes, for example 'A' is 65 and 'a' is 97.
- Distinguishes a digit character such as '7' from the numeric value 7, noting they have different representations.
- Names a typical built-in function that performs the conversion, such as ord() in Python.
- Explains that the conversion applies to a single character, so a string must be processed one character at a time.
Common mistakes and how to put them right
Assuming that the character '7' and the number 7 are the same.
Put it right: The character has its own code (55 in ASCII) which differs from the numeric value.
Believing that 'A' and 'a' share the same code.
Put it right: Upper-case and lower-case letters have different codes, 65 and 97 in ASCII.
Confusing the two directions of conversion.
Put it right: Character-to-code uses a function such as ord(), while code-to-character uses a function such as chr().
Exam tips
- Learn the ASCII codes for a few anchor characters such as 'A' (65) and 'a' (97) so you can work out nearby codes.
- Check whether the question gives an upper-case or lower-case character, because the code differs.
- Read the question carefully to confirm whether it asks for character-to-code or code-to-character before choosing an answer.
Try the lesson
The start of the String handling operations in a programming language: convert character to character code lesson, made from checked teaching notes for this specification point.
Have a go first
A variable holds the single character "a" (lowercase). A character-to-code operation is applied to it. What ASCII code value is returned?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of String handling operations in a programming language: convert character to character code
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge