Input with ask and answer

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Input with ask and answer

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which block shows a question and waits for the user to type a reply?
A ask and wait
B say for 2 seconds
2. A user types their name after an 'ask and wait' block. Where does the reply go?
A Into the answer block
B Into the green flag block
3. Which script saves the answer in a variable called name?
A set name to answer, then ask What is your name? and wait
B ask What is your name? and wait, then set name to answer
4. Which statement about the 'answer' block is true?
A It holds every reply the user has ever typed
B It holds the most recent reply typed into an ask and wait block
5. You ask 'What is your favourite colour?' and the user types 'blue'. Then you ask 'How old are you?' and the user types '11'. What is in the answer block now?
A 11
B blue

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1ask [What is your name?] and wait AThe say block comes before the ask block, so answer is empty or holds an old reply. Ask first, then use answer.
2answer Bask [How old are you?] and wait set [age] to (answer)
3Ask a question, then make the sprite say the reply the user typed. Cask [Favourite food?] and wait say (answer)
4Save the user's reply in a variable so you can use it later, even after asking another question. DThe second ask replaced answer, so pet gets the age. Save the first answer in a variable before asking again.
5say (answer) ask [What is your name?] and wait EShows a question on the stage and waits for the user to type a reply and press enter.
6ask [Your pet's name?] and wait ask [Your age?] and wait set [pet] to (answer) FA reporter block that holds the last reply the user typed after an ask and wait block.

Definitions

ask and wait

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
___ "What is your name?" and wait
2.
ask "What is your name?" and ____
3.
ask "What is your name?" and wait say (______)
4.
ask "Favourite animal?" and wait set pet to (______) say (pet)
5.
ask "Favourite animal?" and wait set ___ to (answer) say (pet)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A ask [Fav colour?] and wait
B say [Fav colour?]
C say (colour)
Question 2
A when green flag clicked
B ask [Your age?] and wait
C set [answer] to (age)
D say (age)
Question 3
A say [Fav colour?]
B set [colour] to (answer)
C say (colour)
Question 4
A when green flag clicked
B ask [Your name?] and wait
C set [name] to (answer)
D say (join [Hi ] [name])
Question 5
A when green flag clicked
B ask [Pick a number]
C if <(answer) = [7]> then
D say [Correct!]
E end

Answer Key

Input with ask and answer
Section A: Quick Questions
Q1
A — ask and wait
Q2
A — Into the answer block
Q3
B — ask What is your name? and wait, then set name to answer
Q4
B — It holds the most recent reply typed into an ask and wait block
Q5
A — 11
Section B: Match the Pairs
Q1
ask [What is your name?] and wait → Shows a question on the stage and waits for the user to type a reply and press enter.
Q2
answer → A reporter block that holds the last reply the user typed after an ask and wait block.
Q3
Ask a question, then make the sprite say the reply the user typed. → ask [Favourite food?] and wait say (answer)
Q4
Save the user's reply in a variable so you can use it later, even after asking another question. → ask [How old are you?] and wait set [age] to (answer)
Q5
say (answer) ask [What is your name?] and wait → The say block comes before the ask block, so answer is empty or holds an old reply. Ask first, then use answer.
Q6
ask [Your pet's name?] and wait ask [Your age?] and wait set [pet] to (answer) → The second ask replaced answer, so pet gets the age. Save the first answer in a variable before asking again.
Section C: Definitions
Q1
ask and wait — A block that shows a question and waits. The user types a reply, and it goes into the answer block. You can use answer straight away or save it in a variable.
Section D: Fill in the Blanks
Q1
ask "What is your name?" and wait
Q2
ask "What is your name?" and wait
Q3
ask "What is your name?" and wait say (answer)
Q4
ask "Favourite animal?" and wait set pet to (answer) say (pet)
Q5
ask "Favourite animal?" and wait set pet to (answer) say (pet)
Section E: Spot the Error
Q1
B — The say block only shows words. It does not wait for a reply or save one in answer. The line should be ask [Fav colour?] and wait.
Q2
C — The blocks are the wrong way round. The variable age should be set to the answer reporter, so it should be set [age] to (answer).
Q3
A — Nothing asks the user for anything, so there is no reply to save. Line 1 should be ask [Fav colour?] and wait.
Q4
D — [name] in square brackets is just the word name, so it would say Hi name. The variable reporter should be in round brackets: (name).
Q5
B — The block is missing 'and wait'. Without it the program does not stop for the user to type, so answer is not ready. It should be ask [Pick a number] and wait.