Skip to content

← Grade 6 Computing

Exam practice

Every question from the end of every unit, with hints and answers to open. After you check an answer, mark how you did, and come back to the ones you didn’t get.

10 questions

Unit 4 · Programming with Blocks

a.

Explain the meaning of these words, with an example of each: program, sequence, loop, event, bug.

Answer
  • Program: a set of exact instructions that a computer carries out. Example: the blocks that make the turtle draw a square; an app on a phone.
  • Sequence: instructions carried out one after another, in order. Example: move 100, then turn right 90, then move 100.
  • Loop: a block that runs the blocks inside it again and again. Example: repeat 4 times: move 100, turn right 90.
  • Event: something that happens, which a program can react to. Example: pressing the up arrow key, tapping an icon on a phone.
  • Bug: a mistake in a program. Example: turning 60° when drawing a triangle, so the shape doesn’t close.
b.

What is the difference between a block-based and a text-based programming language? Give one example of each.

Answer

In a block-based language the program is made by dragging blocks and snapping them together; each block is one instruction, and there is nothing to spell wrong. Example: Scratch (or MakeCode).
In a text-based language the program is typed as words and symbols, which must be exactly right. Example: Python.
Both can say the same things; text is what most professional programmers use.

c.

Write the blocks to draw a square with sides of 60 steps (i) without a loop, and (ii) with a loop. Which is better, and why?

Answer
  • i.Without a loop, 8 blocks: move 60, turn right 90, move 60, turn right 90, move 60, turn right 90, move 60, turn right 90.
  • ii.With a loop, 3 blocks: repeat 4 times: move 60 steps, turn right 90 degrees.

The loop is better: it is shorter, easier to read, and to change the size you change one number instead of four, so there is less chance of a mistake.

d.

Copy and complete the table for regular shapes drawn by the turtle.

Shape Number of sides Turn at each corner
triangle 3
90°
hexagon
10
Answer
Shape Number of sides Turn at each corner
triangle 3 360° ÷ 3 = 120°
square 4 90°
hexagon 6 360° ÷ 6 = 60°
decagon 10 360° ÷ 10 = 36°
e.

Draw on paper what this program makes, and say where the turtle ends up. The turtle starts facing right.
repeat 3 times: move 50 steps, turn left 90 degrees, move 50 steps, turn right 90 degrees

Hint

Draw it one block at a time. Each time round the loop, the turtle draws two lines.

Answer

A staircase of 3 steps going up to the right: across 50, up 50, across 50, up 50, across 50, up 50. The turtle ends at the top of the stairs, 150 steps to the right of where it began and 150 steps higher, facing right again.

f.

A student wants a triangle with equal sides, and writes repeat 3 times: move 100 steps, turn right 60 degrees. What will the turtle draw? Find the bug and fix it.

Answer

The turtle turns only 60° at each corner, half of what it needs. After 3 sides it has turned only 3 × 60° = 180°, so the shape doesn’t close: it draws three sides of a hexagon, half of one.
The bug is the turn: the turtle must turn from the way it was going, 360° ÷ 3 = 120°. The fixed program is repeat 3 times: move 100 steps, turn right 120 degrees.

g.

How many lines does this program draw? repeat 8 times: repeat 4 times: move 40 steps, turn right 90 degrees; turn right 45 degrees. What does the drawing look like?

Answer

The inside loop draws a square, 4 lines. The outside loop runs it 8 times: 8 × 4 = 32 lines. After each square the turtle turns 45°, and 8 × 45° = 360°, so the 8 squares are spread evenly all the way round the starting point, like the petals of a flower.

h.

Name three events that the programs in a mobile phone react to.

Answer

Any three, such as: tapping an icon (opens an app); a call coming in (the phone rings); pressing the volume button (the sound changes); the alarm time arriving (the alarm rings); turning the phone sideways (the picture turns); a message arriving (a sound plays).

i.

What is debugging? Write the four steps of a good way to debug a program.

Answer

Debugging is finding and fixing the mistakes (bugs) in a program.

  1. Predict what the program should do.
  2. Run it, and compare what happens with what you expected: find the first place where they differ.
  3. Change one thing (the block you think is wrong), and run it again.
  4. Go slowly, watching which block runs when the mistake happens.
j.

What is decomposition? Show how you would break the job “draw a flag of two triangles, one above the other, on a pole” into smaller parts.

Answer

Decomposition is breaking a big job into smaller parts that are each easy to do.
For a flag of two triangles on a pole:

  1. Draw the pole: a long line upwards.
  2. Draw the top triangle at the top of the pole.
  3. Move down the pole to where the lower triangle starts.
  4. Draw the lower triangle.

Each part can be built and tested on its own (the triangles with a repeat loop), then joined in order.