Night 16: Name tags
Você já concluiu esta noite, em Python ou pseudocódigo. Ela conta para ambos. Pratique novamente se quiser.
Tonight: name tags
- Your pet wants a name tag. Tonight you build text from pieces.
- You will learn one thing: joining text with
&.
Words for tonight
| Word | Meaning |
|---|---|
| join | put two pieces together into one |
| convert | change a value into another type |
| space | the empty character between words |
Join text with &
&puts two STRINGs together into one STRING.
DECLARE Name, Tag : STRING
Name ← "Kit"
Tag ← "Hello, " & Name & "!"
OUTPUT Tag
&adds no spaces. Write each space inside the quotes.

Numbers must become text first
&joins STRINGs only. Turn a number into a STRING withNUM_TO_STR.
DECLARE Age : INTEGER
Age ← 2
OUTPUT "Kit is " & NUM_TO_STR(Age) & " years old"
OUTPUT "Next year: " & NUM_TO_STR(Age + 1)
Commas or &?
| Code | What it does |
|---|---|
OUTPUT "Age: ", Age |
outputs the two values one after the other |
"Age: " & NUM_TO_STR(Age) |
makes one STRING you can store |
- Use commas to output quickly. Use
&when you need the text in a variable. - Now make some name tags!
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Read a name, then an age. Join the text with & to output Kit is 2 years old. Use NUM_TO_STR for the age.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Read a snack and a price. Put a price tag like apple: 3 coins in the STRING Tag, then output Tag.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Read a name and an age. Output Next year Kit is 3. Work out Age + 1 inside NUM_TO_STR.
Clique em Executar para ver a saída aqui.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
Read a name, a kind and a number of nights. Output a 3-line card: Name: Kit, then Kind: fox, then Nights: 12/30.
Clique em Executar para ver a saída aqui.