Night 3: Talk to your pet
You already finished this night, in Python or pseudocode. It counts for both. Practise again if you like.
Tonight: talk to your pet
- Your pet has a name. Now it wants to know your name.
- You will learn one thing:
INPUT.
Words for tonight
| Word | Meaning |
|---|---|
| input | what the user types into the program |
| user | the person who uses the program |
| wait | stop and do nothing until something happens |
INPUT waits for the user
INPUT Namestops the program and waits.- The user types something and presses Enter.
- The typed words go into the variable
Name. Declare it first.
DECLARE Name : STRING
OUTPUT "What is your name?"
INPUT Name
OUTPUT "Hello, ", Name
- Press Run. A box opens. Type your name and press Enter.

Never type the answer yourself
- Do not write
Name ← "Sam". Then the program always says Sam. INPUTlets every user give a different answer.- The checker types different names to test your program.
Ask, wait, answer
- Many programs work like this:
-
- Ask a question with
OUTPUT.
- Ask a question with
-
- Wait for the answer with
INPUT.
- Wait for the answer with
-
- Answer with
OUTPUT, using the variable.
- Answer with
DECLARE Food : STRING
OUTPUT "What is your favourite food?"
INPUT Food
OUTPUT "Yum! ", Food, " is great!"
Now you try
- Do the tasks below. Press Run and type an answer.
- Then press Check answer. The checker types some answers for you.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
Your pet asks your name. Read it with INPUT Name. Then output Nice to meet you, and the name. For the name Sam, the output is Nice to meet you, Sam.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Your pet asks: What colour? Read the answer into Colour. Then output I will paint my house and the colour. For blue, the last line is I will paint my house blue.
Clique em Executar para ver a saída aqui.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
Read dois answers with two INPUT lines: first a name into Name, then a city into City. Then output one line like Sam lives in Ningbo.
Clique em Executar para ver a saída aqui.