Lesson 46: Message on the floor
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
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" |
English
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 |
English
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) is(是) "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.
点击“运行”查看此处输出。