Lesson 46: Message on the floor
Text is numbers
- A computer stores each character as a number: its character code.
- ASCII is a character set: A is 65, H is 72, a is 97, ? is 63.
- Each code is stored as 8 bits (one byte). Here the bits are tiles on the floor.
Words for this lesson
| Word | Meaning |
|---|---|
| character set | a list of characters and their codes |
| ASCII | a character set for English letters, digits and signs |
| Unicode | a bigger character set for every language |
| chr() | gives the character for a code: chr(72) is "H" |
Read a letter
| Tiles | Bits | Code | Letter |
|---|---|---|---|
| blue black blue blue black blue blue blue | 01001000 | 72 | H |
| blue black black blue blue black blue black | 01100101 | 101 | e |
In the exam
- 0478/11/O/N/24 Q3: the character A is ASCII 65 and m is 109. (a) Another character set: Unicode. (b)(i) In binary: 01000001 and 01101101. (ii) In hexadecimal: 41 and 6D.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Eight tiles hide one character: black is 1, blue is 0. read_byte drives over them and works out the number, but one line is missing. Add it. Then print the code and its character: chr(72) هي "H". Print it like this: Code: 72, letter: H.
اضغط تشغيل لرؤية المخرجات هنا.
الصعوبة 4/5 · 280 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Now the floor holds a 3-letter message in three columns. next_column(n) moves the robot to the start of the next column. Read 3 bytes, add each letter to message, and print Message: and the message. Do not call next_column after the last letter, or the robot leaves the floor.
اضغط تشغيل لرؤية المخرجات هنا.