AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Term 3 review

Week 30 · Review: Term 3 · 3 lessons
2

Scores, criteria and routes

Computing 5: Units 9–12, pp. 119–170
GoalReview scores with + and −, criteria for a game, and how to compare algorithms.
New words
variable · a named place that stores a value that can changecriterion · one result that a program must achieve, which can be tested with yes or noefficient · using the fewest steps or the least timetime cost · the number of seconds that one step takes
Explanation

A game keeps its score in a variable. The program sets a start value and then adds or takes away points with + and −, for example with change score by 3. Before we build a game, we write criteria that can be tested with a clear yes or no. After building, we evaluate it. We check that the code matches the algorithm and run a test for each criterion. A fix needs a retest of all the criteria. Two algorithms can do the same job, but the efficient one uses fewer steps or less time. A repeat block can shorten a program. For a robot, the time is forwards × time + turns × time.

Hedgehogwhenclickedsetstarsto10askHow many legs has a crab?and waitchangestarsby5changestarsby-4ifanswer=10thenelse
Worked examples
AfterResultCalculationstars
start10
question 1right10 + 515
question 2wrong15 − 411
question 3wrong11 − 47
The score starts at 10. A right answer adds 5 and a wrong answer takes away 4. A player answers right, wrong and wrong. Each row starts from the score of the row above.
CriterionResult
1 The car moves 10 steps when the right arrow key is pressedyes
2 The car stops when it touches the finish lineno
3 The timer starts at 0yes
A tester ran a car race game. Two criteria pass and one fails, so the tester looks at the code for the finish line.
A
A robot takes 1 second for a forward move and 4 seconds for a turn. Route Y (the staircase) has 6 forwards and 4 turns, so it takes 6 + 16 = 22 seconds. Route X goes straight along the bottom and then up: it has 6 forwards and 1 turn, so it takes 6 + 4 = 10 seconds. Route X is more efficient.
Class activity

Score and route game (pairs, paper). Player A reads 5 quiz questions. Player B answers. Use the rule: start at 6, right +2, wrong −1. Write the new score after each question. Then draw a grid of 5 × 4 squares, put a start and a flower on it and find two routes. Work out the time of each route with forward = 1 second and turn = 4 seconds. Which route is more efficient?

Practice
1
The Owl starts with 3 stars. This program has no else part. What does stars hold if the player types 4? What if the player types 3?
Owlwhenclickedsetstarsto3askHow many sides has a triangle?and waitchangestarsby2ifanswer=3then
2
Which of these criteria can be tested with a clear yes or no? (a) The game looks great. (b) The kite gets 1 point for each star it touches. (c) The game is easy. (d) The game says ‘Done’ when the score is 4.
3
Forward takes 1 second and a turn takes 4 seconds. How long does this route take?
4
Why does a repeat block make a program more efficient?