GCSE · Computer Science · AQA · Spec 8525
Convert character code to character
Secret message: 71 111 52 105 116. It's a real word, and every number is the code for one character. Let's decode it.
Decode a hidden word
71 111 52 105 116 — what does it say?
Every character has a number, called its character code. Here is part of a code table (these are the codes ASCII uses): 52 → 4 · 55 → 7 · 71 → G · 72 → H · 79 → O · 105 → i · 111 → o · 116 → t. The program hands each code to CODE_TO_CHAR, which looks it up and gives back one character. Step through and watch the word appear.
Before each Next, find the code in the table and say the character it will give back.
1 word ← ""2 word ← word + CODE_TO_CHAR(71)3 word ← word + CODE_TO_CHAR(111)4 word ← word + CODE_TO_CHAR(52)5 word ← word + CODE_TO_CHAR(105)6 word ← word + CODE_TO_CHAR(116)7 OUTPUT word
| code in | character out | word |
|---|---|---|
| "" |
Output
Step 1: word starts empty. Nothing has been converted yet.
Use Next and Back to step. Each row shows the code that went in and the character that came out.
Predict, then check
Commit to an answer before you reveal it.
A program runs d ← CODE_TO_CHAR(55). The code table says 55 → 7. What is stored in d?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
What you need to know
- Every character has a whole-number character code, listed in a code table.
- Converting a character code to a character gives back the one character that code stands for, e.g. CODE_TO_CHAR(71) or chr(71) gives G.
- The result is always a character, which is text, even when that character is a digit such as 7.
- To reach a different character, do the arithmetic on the code first, then convert: CODE_TO_CHAR(code + 1).
The big picture
Converting a character code to a character is a string handling operation: you give it a whole-number code and it gives back the one character that code stands for in the character set's code table. In pseudo-code it is often written CODE_TO_CHAR(code); in Python it is chr(code). The result is always a character, even when it is a digit, so any arithmetic must be done on the code before converting.
Key points
Worked example
Problem
Use this code table: 65 → A, 66 → B, 67 → C, 68 → D. What does this program output? n ← 65 n ← n + 2 c ← CODE_TO_CHAR(n) OUTPUT c + c
⚠ Watch out
Thinking that converting a code for a digit gives you the number. CODE_TO_CHAR(55) gives the character 7, which is text, so joining it to the character 1 makes the text "71" rather than adding up.
Memory hook
Number in, character out, and once it's a character the maths is over.
Check yourself
Using the table 104 → h and 105 → i, what does OUTPUT CODE_TO_CHAR(104) + CODE_TO_CHAR(105) display, and why is the answer not a number?
Flashcards
(6)What goes in and what comes out when you convert a character code to a character?
How is this operation written in Python, and in pseudo-code?
With the table 52 → 4, is CODE_TO_CHAR(52) the number 4?
Does code 111 give a capital O or a lower-case o?
With 71 → G and 72 → H, how do you get H from the code 71?
What is the name of the operation that goes the other way?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.