Year 8 · Y8.2 Computational Thinking · Lesson 3
Stretch tasks Pseudocode and testing
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Pseudocode and testing
Pseudocode and testing: the questions
Quiz Challenge, round 1: Quiz Blitz
What is printed?
total = 0 for i = 1 to 4 total = total + i next i print(total)An age box accepts 11 to 18. Which value is BOUNDARY test data?
- fifteen
- 18
- 14
- 25
The same age box accepts 11 to 18. Which value is ERRONEOUS test data?
- 11
- 15
- 18
- hello
Pseudocode must follow exact syntax rules, or it will not run.
- True
- False
What is printed?
x = 3 y = x * 2 x = y + 1 print(x)- 6
- 3
- 4
- 7
Put these steps for solving a programming problem in a sensible order.
Number these 1 to 4.
- Write the algorithm in pseudocode
- Write the code
- Test with normal, boundary and erroneous data
- Decompose the problem
Why plan in pseudocode before coding? Pick TWO.
Tick 2.
- The same plan works in any language
- Pseudocode runs faster than Python
- It removes the need for testing
- Computers can run pseudocode directly
- Logic mistakes are cheaper to fix on paper
How many times is Hi printed?
count = 0 while count < 3 print("Hi") count = count + 1 endwhile- 2
- 4
- It never stops
- 3
What is a trace table used for?
- Drawing the shapes of a flowchart
- Storing only the final output of a program
- Timing how long a program takes to run
- Recording the value of each variable at each step
What is printed?
n = 5 answer = 1 for i = 1 to n answer = answer * i next i print(answer)Boundary data is often the most useful test data, because mistakes hide at the edges.
- True
- False
A program should accept marks from 0 to 100. Which set of tests is best?
- abc and xyz
- -1, 0, 50, 100, 101 and abc
- 50, 60 and 70
- 0 and 100
Quiz Challenge, round 2: Quick Fire
A box accepts shoe sizes from one up to thirteen. Give one example each of normal, boundary and erroneous test data. [3 marks]
Explain why erroneous data is used when testing. [2 marks]
Trace the algorithm. What is the final value of total? [1 mark]
total = 0 for i = 1 to 3 total = total + i * 2 next iWhy is pseudocode easier to plan with than a real programming language? [2 marks]
Quiz Challenge, round 3: Big Think
A game asks for the player's age and must only accept ages from eight to sixteen. Explain how you would test it, with examples of test data. [4 marks]
Explain why planning an algorithm with pseudocode and a trace table can save time, even though the planning takes time at the start. [6 marks]
This or That: tick the right answer
Can pseudocode be run on a computer?
- No: it is a plan in structured English
- Yes: it is a programming language
What is printed?
x = 10 for i = 1 to 3 x = x - i next i print(x)- 4
- 7
An age box accepts 0 to 120. Which is normal test data?
- 120
- 25
A box asks how many pets you have. Which is erroneous test data?
- 3
- "lots"
A program accepts whole numbers from 1 to 10. Which pair are both boundary values?
- 1 and 10
- 5 and 6
Where is a mistake in logic cheapest to fix?
- On paper, in the plan
- In the finished program
In a trace table, what does each row show?
- Only the program's output
- Every variable's value at one step
Which plan can be turned into Python, Java or any other language?
- A pseudocode plan
- A Python program
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Pseudocode | 1 A value that should be rejected |
| B Trace table | 2 A value right at the edge of what is allowed |
| C Normal data | 3 Shows each variable's value at every step |
| D Boundary data | 4 The exact rules for writing a real language |
| E Erroneous data | 5 A typical value that should be accepted |
| F Syntax | 6 An algorithm written in structured English |
Answers
Round 1: Quiz Blitz
- 10 total becomes 1, then 3, then 6, then 10.
- 18 Boundary data sits right at the edge of what is allowed: 11 and 18 here.
- hello Erroneous data is the wrong type or makes no sense, and the program should reject it.
- False Pseudocode never runs. It is for planning, so it only has to be clear to a person.
- 7 y becomes 6, then x becomes 6 + 1 = 7. The old value of x is overwritten.
- Decompose the problem → Write the algorithm in pseudocode → Write the code → Test with normal, boundary and erroneous data Understand and break down the problem, plan it, build it, then prove it works.
- Logic mistakes are cheaper to fix on paper; The same plan works in any language A plan is cheap to change and is not tied to one language. It still has to be coded and tested.
- 3 count is 0, 1 and 2 when the loop runs. When count reaches 3, the condition is false and the loop ends.
- Recording the value of each variable at each step Following every variable step by step is how you prove an algorithm really does what you think.
- 120 1 x 1 x 2 x 3 x 4 x 5 = 120. This algorithm works out a factorial.
- True A > typed where >= was meant only shows up at the boundary. Normal data would pass either way.
- -1, 0, 50, 100, 101 and abc Good test data covers normal values, both boundaries, just outside them, and erroneous input.
Round 2: Quick Fire
- Normal: a typical value inside the range, such as 7
- Boundary: 1 or 13
- Erroneous: an invalid value such as 0, 14 or a word
Model answerNormal: 7. Boundary: 1 or 13. Erroneous: hello, or 14, which is out of range.
- To check the program rejects invalid input
- So that it does not crash or give wrong results
Model answerErroneous data checks that the program rejects invalid input, such as text where a number should be, so that it does not crash or produce wrong results when a user makes a mistake.
- 12
Model answer12. total goes 2, then 6, then 12.
- There are no strict syntax rules to get exactly right
- So you can focus on the logic of the algorithm
- It can be turned into any language
Model answerPseudocode has no strict syntax rules, so missing brackets or colons do not matter. That lets you focus on the logic of the algorithm, and the plan can then be converted into any language.
Round 3: Big Think
- Normal data, such as 12
- Boundary data: 8 and 16, and just outside at 7 and 17
- Erroneous data, such as a word or a negative number
- Record the expected result and compare it with the actual result
- Fix any failures and test again
Model answerI would write a test plan with the expected result for each test, then compare it with the actual result. I would use normal data such as 12, which should be accepted. I would use boundary data: 8 and 16 should be accepted, and 7 and 17, just outside, should be rejected. I would use erroneous data such as ten written as a word, or -3, which should be rejected with a message. If any actual result did not match, I would fix the code and test again.
- Logic errors are found before any code is written
- Errors are cheaper and quicker to fix in a plan than in code
- A trace table shows each variable's value at each step, which reveals mistakes
- The plan can be shared for feedback
- The same plan works in any language and can be reused
- Writing the plan shows up steps that had been forgotten
- Coding is quicker with a clear plan, with less debugging later
Model answerPlanning finds mistakes in the logic early, on paper, before any code is written, and they are far cheaper and quicker to fix there than in a finished program. A trace table follows the value of each variable at each step, so it shows exactly where an algorithm goes wrong. Writing the plan also shows up steps that had been forgotten, and the plan can be shared with someone else for feedback. Because the same plan works in any language it can be reused, and coding from a clear plan is faster, with much less debugging later.
This or That
- No: it is a plan in structured English Pseudocode is not a real language, so it will not run. It lets you plan the logic without worrying about syntax.
- 4 x goes 10, then 9, then 7, then 4, because 1, 2 and 3 are taken away in turn.
- 25 25 is a typical value that should work. 120 sits right at the edge, so it is boundary data.
- "lots" Text is the wrong type of data entirely, so the program should reject it.
- 1 and 10 Boundary data sits right at the edges of what is allowed.
- On paper, in the plan Changing a plan takes minutes. In finished code you have to find the mistake and rewrite around it.
- Every variable's value at one step A trace table records the value of every variable at every step, so you can check the algorithm works.
- A pseudocode plan Pseudocode is not tied to one language, so the same plan works in all of them.
Memory Match
- A 6 Pseudocode: An algorithm written in structured English
- B 3 Trace table: Shows each variable's value at every step
- C 5 Normal data: A typical value that should be accepted
- D 2 Boundary data: A value right at the edge of what is allowed
- E 1 Erroneous data: A value that should be rejected
- F 4 Syntax: The exact rules for writing a real language