Night 2: Give your pet a name
You already finished this night, in Python or pseudocode. It counts for both. Practise again if you like.
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Tonight: give your pet a name
- Last night your pet woke up. Tonight it gets a name.
- You will learn one thing: variables.
Words for tonight
| Word | Meaning |
|---|---|
| variable | a box with a name; it keeps a value |
| value | what is inside the box, like "Lumi" or 7 |
| type | what kind of value the box keeps: STRING is text, INTEGER is a whole number |
English
A box with a name
- First make the box:
DECLARE, the name,:, then the type. - Then put a value in it with the arrow
←. It means put into the box. - You can type
<-. The editor turns it into←.
DECLARE PetName : STRING
PetName ← "Lumi"
OUTPUT PetName
OUTPUT PetNamehas no quotes. So you see what is in the box.

English
Quotes or no quotes?
- With quotes, you get the word itself.
- Without quotes, the computer looks for a box with that name.
DECLARE PetName : STRING
PetName ← "Lumi"
OUTPUT "PetName"
OUTPUT PetName
English
Output two things
- Put a comma between the things after
OUTPUT. - The comma joins them with no space. So put the space inside the quotes:
"Hello, ".
DECLARE PetName : STRING
PetName ← "Lumi"
OUTPUT "Hello, ", PetName
English
A new value
- You can put a new value in the same box.
- The old value is gone. The box keeps only the newest one.
DECLARE Mood : STRING
Mood ← "sleepy"
Mood ← "happy"
OUTPUT Mood
English
Good names
- Start with a capital letter. Join words with no space:
PetName,BestFood. - Do not start with a number.
- Use the same spelling every time you use the name.
English
Now you try
- Do the tasks below. Press Run, then Check answer.
- When all tasks pass, your pet knows its name.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The box PetName is declared. Put the text "Lumi" in it with ←.
点击“运行”查看此处输出。
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
PetName 持有 "Lumi". Output My name is and the name on one line, so the output is My name is Lumi. Use the variable, not the word Lumi.
点击“运行”查看此处输出。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Your pet wants a new name. Put "Nova" 入 PetName on the empty line. Do not change the OUTPUT line. The output should be Hi, I am Nova.
点击“运行”查看此处输出。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Declare two STRING variables, PetName and Food. Put "Kit" 入 PetName and "apples" 入 Food. Then output Kit likes apples using 两者 variables.
点击“运行”查看此处输出。