HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Text, Sound and Images in Binary
  1. 1Text and character sets
  2. 2Sound: sample rate and sample resolution
  3. 3Images: resolution and colour depth
  1. Computer Science
  2. /Text, Sound and Images in Binary
  3. /Text and character sets

Course 1.2·Lesson 1 of 3

Text and character sets

A computer stores text by giving every character a number and storing that number in binary. You learn what a character set is, how ASCII and Unicode work, why Unicode can show far more characters, and how many bits a piece of text needs.

about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Text, Sound and Images in Binary
  1. 1Text and character sets
  2. 2Sound: sample rate and sample resolution
  3. 3Images: resolution and colour depth

Try the code and the simulations beside the lesson.

Every letter is a number

When you press the key A, the computer does not store a picture of the letter. It stores a number. The keyboard sends a code, and the computer keeps that code in binary, just like any other number. Text is turned into binary so that the computer can process it.

A character is any single letter, digit, space, punctuation mark or symbol. A character set is the list of all the characters a computer can use, with the binary code of each one. The sender and the receiver must use the same character set, or the text comes out as nonsense.

ASCII

ASCII stands for American standard code for information interchange. It is one of the oldest character sets.

  • Standard ASCII uses 7 bits for each character. That gives 27=1282^7 = 12827=128 different codes, numbered 0 to 127.
  • It holds the capital and small English letters, the digits 0 to 9, punctuation, the space, and some control codes such as a new line.
  • In memory each character usually takes one byte (8 bits). An extended form of ASCII uses all 8 bits for 256 characters.
A short part of the ASCII table in three columns: character, denary code and 7-bit binary code. Capital A is 65 (1000001), B is 66, C is 67, D is 68 and E is 69. Small a is 97 (1100001), b is 98 and c is 99. The digit character 0 is 48 (0110000) and 1 is 49. The space is 32. A note says that a small letter is 32 more than its capital.

The codes follow a pattern, so you can work many of them out.

CharacterDenaryBinary
A651000001
B661000010
a971100001
0480110000
  • The letters are in order. If A is 65, then B is 66, C is 67 and so on.
  • A small letter is 32 more than its capital. So a is 65+32=9765 + 32 = 9765+32=97.
  • The digit characters are in order too. The character 0 is 48, so 5 is 53.

Notice that the character 5 (code 53) is not the number 5. A character code is only a label for a symbol.

Unicode

ASCII has room for only 128 characters. That is enough for English, but not for the letters of other languages, mathematical symbols or emojis.

Unicode is a much larger character set. It allows a far greater range of characters and symbols than ASCII, including those of many different languages and emojis. To do this, Unicode needs more bits per character than ASCII. Common forms use 16 or 32 bits for each character. An examination question tells you how many bits each character uses.

The first 128 Unicode characters have the same codes as ASCII, so the letter A is 65 in both.

How much space does text need?

The number of bits a piece of text needs is easy to work out.

bits=number of characters×bits per character\displaystyle \text{bits} = \text{number of characters} \times \text{bits per character}bits=number of characters×bits per character

A message of 20 characters in 8-bit ASCII needs 20×8=16020 \times 8 = 16020×8=160 bits, which is 20 bytes. The same message in a 32-bit Unicode form needs 20×32=64020 \times 32 = 64020×32=640 bits. Every space and punctuation mark counts as a character.

Practise with new numbers

Try it in Python

Python's ord gives the code of a character and chr gives the character for a code. The program prints the codes of a word in denary and in 8-bit binary, then turns the word into small letters by adding 32.

Read it first. Then run it. What is the code of the letter O?

1. Change the word to your own name in capital letters. Predict the code of the first letter before you run it.

2. Put a space in the word. What code does the space get?

Common mistakes

  • Mixing up the character and the number. The character 7 has the code 55. It is not stored as the number 7.
  • Forgetting spaces. A space is a character and needs bits like a letter does.
  • Saying Unicode is smaller. Unicode allows more characters, so it needs more bits per character.
  • Mixing bits and bytes. Divide a number of bits by 8 to get bytes.

Remember these

  • A character set gives every character a binary code.
  • ASCII uses 7 bits (128 characters), usually stored in one byte each.
  • Unicode has far more characters, including other languages and emojis, and needs more bits per character.
  • Bits for a text === number of characters ×\times× bits per character.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. The ASCII code of the letter A is 65. What is the code of the letter K?
  1. The ASCII code of M is 77. What is the code of m?
  1. A text has 45 characters and uses 16 bits a character. How many bytes does it need?
  1. Give one reason why a messaging app uses Unicode and not ASCII.
  1. Why does a text stored in Unicode usually take more space than the same text in ASCII?

Enroll free in Text, Sound and Images in Binary

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A student knows only one ASCII code: the capital letter A is 65…Easy · High School (9–10) · by StemPy Lab
A phone message is 160 characters long, spaces included…Medium · High School (9–10) · by StemPy Lab
A team designs a character set for a language with 1200 different characters…Hard · High School (9–10) · by StemPy Lab
Next: lesson 2Sound: sample rate and sample resolution
← Text, Sound and Images in Binary
← PreviousSound: sample rate and sample resolution →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

Python Labs (1)

Character codes in PythonPython Lab · by StemPy Lab