ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions

N5 Computing Science 2014 Question 20

10 marks · Fixed and conditional loops

Write the code that would draw a hexagon. Hexagon(n) 60° 60° n pixels long Starting point Describe one way you could make the programmer’s code more readable. Suggest a new pre-defined function that could be added to this programming language. The following program uses the Square(n) function to draw a pattern. Two values have been missed out from the code. Complete the code by filling in the values in the two boxes. Direction of first move Starting point REPEAT TIMES square(n) rotate( ) END REPEAT The shapes that are drawn by the program can be saved as vector graphics. Describe how a square would be saved as a vector graphic. Every time a new function is added to the programming language it is designed using pseudocode. State another design notation that could be used to design the new functions. A programming language provides the following pre-defined functions. move(n) n = distance moved in pixels rotate(d) d = degrees turned (positive means clockwise) These can be used by the programmer to draw lines. A programmer writes the code to draw a square. The code is shown below. Square(n) REPEAT 4 TIMES move(n) rotate(90) END REPEAT 90° turn 90° turn n pixels long Starting point

Marking scheme

REPEAT 6 (1 mark) END REPEAT move(n) (1 mark) rotate(60) (1 mark) Unconditional loop (1 mark) Movement of n (1 mark) Rotation of 60 (1 mark) 1 mark each any of • Internal commentary • Meaningful identifiers • Modularisation • White space • Indentation Any suitable function. For example: • Polygon (any shape) • Text tool • Fill Not “hexagon” or “square” as they are given in the question. 8 45 Watch for other solutions 8,135 would also draw the correct pattern of squares. Square requires: startx, starty (1 mark) length, rotation (1 mark) Award 1 mark for a description of attributes of an object being stored but no detail. Structure Chart or Flow Diagram/Chart 1 mark for any other contemporary design notation.

Previous question: N5 Computing Science 2014 Question 19

Next question: N5 Computing Science 2014 Question 21