Turning an algorithm into a visual program

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

Turning an algorithm into a visual program

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. An algorithm step says: SET score TO 0. Which block matches it?
A set score to 0
B ask and wait
2. An algorithm step says: ASK 'What is your name?'. Which block matches it?
A ask What is your name? and wait
B say What is your name? for 2 seconds
3. An algorithm says: REPEAT 10 TIMES. Which block should you use?
A if 10 then
B repeat 10
4. An algorithm says: IF score > 5 THEN. Which block matches this step?
A if score > 5 then
B repeat score > 5
5. After you build a visual program from an algorithm, what should you do next?
A Leave it, because blocks never have mistakes
B Run it and check it does what the algorithm says

Match the Pairs

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

Left columnRight column
1SET score TO 0 ASET was matched to the wrong block. 'change' adds to the old value instead of giving a fresh starting value.
2ASK "What is your name?" BASK was matched to 'say', which only shows a message. It does not wait for an answer.
3An algorithm step that makes a decision becomes an 'if' block with the condition inside it CREPEAT 10 TIMES
4An algorithm step that repeats a set number of times becomes a 'repeat 10' block DIF score > 5 THEN
5Algorithm: SET lives TO 3. Program: a 'change lives by 3' block EBecomes an 'ask What is your name? and wait' block
6Algorithm: ASK "Your age?". Program: a 'say Your age?' block FBecomes a 'set score to 0' block in the visual program

Definitions

step -> block

Fill in the Blanks

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

1.
SET score TO 0 ___ score to 0
2.
ASK for the player's name ___ What is your name? and wait
3.
IF score > 5 THEN __ <score > 5> then
4.
REPEAT 4 TIMES repeat _
5.
ask What is your name? and wait set name to ______

Spot the Error

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

Question 1
A when green flag clicked
B change score by 0
C ask [2 + 3 = ?] and wait
D if <answer = 5>
E change score by 1
Question 2
A when green flag clicked
B set steps to 0
C repeat 5
D set steps to 1
E say steps
Question 3
A say [Your name?] and wait
B set name to answer
C say (join [Hi ] (name))
Question 4
A make total equal 0
B repeat 4
C change total by 5
D say total
Question 5
A when green flag clicked
B ask [Colour?]
C if <answer = blue>
D say [Nice choice!]

Answer Key

Turning an algorithm into a visual program
Section A: Quick Questions
Q1
A — set score to 0
Q2
A — ask What is your name? and wait
Q3
B — repeat 10
Q4
A — if score > 5 then
Q5
B — Run it and check it does what the algorithm says
Section B: Match the Pairs
Q1
SET score TO 0 → Becomes a 'set score to 0' block in the visual program
Q2
ASK "What is your name?" → Becomes an 'ask What is your name? and wait' block
Q3
An algorithm step that makes a decision becomes an 'if' block with the condition inside it → IF score > 5 THEN
Q4
An algorithm step that repeats a set number of times becomes a 'repeat 10' block → REPEAT 10 TIMES
Q5
Algorithm: SET lives TO 3. Program: a 'change lives by 3' block → SET was matched to the wrong block. 'change' adds to the old value instead of giving a fresh starting value.
Q6
Algorithm: ASK "Your age?". Program: a 'say Your age?' block → ASK was matched to 'say', which only shows a message. It does not wait for an answer.
Section C: Definitions
Q1
step -> block — Turn each algorithm step into a matching block: SET becomes set, ASK becomes ask and wait, IF becomes if, REPEAT becomes repeat. Then run it to check it does what the algorithm says.
Section D: Fill in the Blanks
Q1
SET score TO 0 set score to 0
Q2
ASK for the player's name ask What is your name? and wait
Q3
IF score > 5 THEN if <score > 5> then
Q4
REPEAT 4 TIMES repeat 4
Q5
ask What is your name? and wait set name to answer
Section E: Spot the Error
Q1
B — The algorithm step is SET score to 0, so it needs the 'set' block. 'change ... by' only adds to the old value, so the score would not start at 0. It should be: set score to 0.
Q2
D — Each time round the loop the algorithm adds 1 to steps, so it needs the 'change by' block. 'set' would put steps back to 1 every time. It should be: change steps by 1.
Q3
A — The algorithm step ASK becomes the 'ask and wait' block. 'say' only shows a speech bubble and does not wait for the user to type. It should be: ask [Your name?] and wait.
Q4
A — There is no 'make ... equal' block. The algorithm step SET becomes the 'set ... to' block. It should be: set total to 0.
Q5
B — The ASK step becomes the 'ask and wait' block. Without 'and wait' the program does not stop for the typed answer, so 'answer' is not ready for the if block. It should be: ask [Colour?] and wait.