AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Convert character code to character
Full specification wording
String handling operations in a programming language: convert character code to character
Converting a character code to a character means taking an integer that represents a character in the computer's encoding and finding the character it stands for.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 6 of 11
Study notes
From the checked teaching notes for this specification point.
The idea
Converting a character code to a character means taking an integer that represents a character in the computer's encoding and finding the character it stands for. This is the reverse of converting a character to its code. In many languages a built-in function performs this: in Python, chr(65) returns 'A' and chr(97) returns 'a'. The integer must be a valid code in the encoding being used, such as ASCII or Unicode, otherwise the result may be an unexpected or unprintable character. To answer a question on this, take the given integer, apply the encoding rule, and state the single character it represents. Remember that different codes give different characters, and that a code such as 55 represents the digit character '7', not the number 7. The operation produces one character at a time.
What earns the marks
- States that converting a character code to a character returns the character that the encoding represents with that integer.
- Identifies the correct character for a given code, for example that 65 gives 'A' in ASCII.
- Recognises that different codes give different characters, for example 65 gives 'A' and 97 gives 'a'.
- Distinguishes a code such as 55, which represents the digit character '7', from the numeric value 7.
- Names a typical built-in function that performs the conversion, such as chr() in Python.
- Explains that the code must be valid in the encoding used, otherwise the result may be unexpected or unprintable.
Common mistakes and how to put them right
Assuming that the code 7 produces the character '7'.
Put it right: The digit character '7' has code 55 in ASCII, while 7 is a different control code.
Believing that 65 and 97 produce the same character.
Put it right: 65 gives upper-case 'A' and 97 gives lower-case 'a'.
Confusing the two directions of conversion.
Put it right: Code-to-character uses a function such as chr(), while character-to-code uses a function such as ord().
Exam tips
- Learn the ASCII codes for a few anchor characters such as 65 for 'A' and 97 for 'a' so you can work out nearby characters.
- Check whether the given code falls in the upper-case or lower-case range before deciding the character.
- Confirm whether the question asks for code-to-character or character-to-code before selecting an answer.
Try the lesson
The start of the String handling operations in a programming language: convert character code to character lesson, made from checked teaching notes for this specification point.
Have a go first
A program holds the integer value 66 and converts it to a character using ASCII. Which character is produced?
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 code to character
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