0% found this document useful (0 votes)
70 views32 pages

SA SA SA SA2 2 2 2 Programming Programming Programming Programming

This document provides a revision manual and answer scheme for a SA2 Scratch programming assessment. It contains 30 multiple choice questions testing concepts related to programming constructs, stages of the programming process, variables, debugging, and more. It also provides the answers to the multiple choice questions.

Uploaded by

dog dog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views32 pages

SA SA SA SA2 2 2 2 Programming Programming Programming Programming

This document provides a revision manual and answer scheme for a SA2 Scratch programming assessment. It contains 30 multiple choice questions testing concepts related to programming constructs, stages of the programming process, variables, debugging, and more. It also provides the answers to the multiple choice questions.

Uploaded by

dog dog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

SA2

SA2 PROGRAMMING
REVISION MANUAL ANSWER SCHEME

Monash University Foundation Year 10/16/20 MUF0051 ICT UNIT 1


MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

MULTIPLE CHOICE QUESTIONS


1. Which of the following is not one of the three core programming constructs?
a. Sequence
b. Selection
c. Repetition
d. Coding
2. Which of the following is the correct sequence of project stages in programming?
a. Application requirements → development → design → evalua"on
b. Application design →requirement → development → evalua"on
c. Application requirement → design → development → evalua"on
d. Application evaluation → development → design → requirement
3. Which of the following are TRUE regarding programming languages?
a. Programming languages are used to create applications.
b. Programming languages are used to create instructions which are sent to the CPU.
c. Programming languages are used to create software.
d. All of the above
4. How is a sprite animated in a Scratch application?
a. By adding a timer to restrict the time allowed to complete a level
b. By changing the sprite’s costume
c. By changing the backdrop
d. By adding and using a variable
5. Testing and debugging a program occur during which project stage?
a. Application requirement
b. Application design
c. Application development
d. Application evaluation
6. Which of the following are advantages of object-oriented programming?
a. It’s easy to break down a problem into small pieces and tackle each separately.
b. It’s easier to reuse functionality from one project to another.
c. It’s considerably easier to debug a well-written OOP application if something goes wrong
d. All of the above

1
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

7. In testing programs, GIGO (garbage in, garbage out) highlights:


a. The needs for comprehensive checking in programs to reduce the possibilities of invalid
input being accepted as valid input to a program
b. The need for documentation in programs to enhance the communications among
development teams
c. The need for formatting and modularizing code to improve readability and ease debugging
of code
d. None of the above
8. When the following codes are executed, the value stored in variable B will be
when green flag licked
set A to 1
set B to 2
set A to A+1
set B to A+B
stop script
a. 1
b. 2
c. 3
d. 4
9. When the following pseudocode is executed with variables YearEntered and NextYear in
Scratch, the output to the user who inputs 2020 will be
when green flag clicked
ask “Enter a year” and wait
set YearEntered to answer
set NextYear to YearEntered+1
say “It is ” and NextYear and “next year”
stop script
a. It is 2021 next year
b. It is 2021next year
c. It is 2020 next year
d. It is 2020next year

2
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

10. The application must contain a timer and three levels' will appear in which stage?
a. Development
b. Design
c. Evaluation
d. Requirements

11. Custom sprites are created in which stage?


a. Design
b. Development
c. Requirements
d. Evaluation
12. In programming, a variable is used to
a. store data which changes each time the program executes
b. give instructions to the CPU so that it can perform a task
c. control a Sprite in Scratch
d. none of the above
13. In which order are the stages completed when creating an application?
a. Design, development and evaluation
b. Development, design and evaluation
c. Evaluation, development then design
d. Debugging then testing
14. What is evaluation?
a. Planning something.
b. Adding a costume to a sprite.
c. Making a judgement about something.
d. Building something.
15. How is debugging different to testing?
a. Debugging creates errors while testing fixes errors.
b. Debugging is searching for errors while testing is fixing errors.
c. Testing is searching for errors while debugging is fixing errors.
d. They are exactly the same!

3
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

16. The programming construct ITERATION such as the Forever block in Scratch refers to:
a. performing an action if a certain condition is true
b. comparing the values in two variables
c. branching from one part of a program to another
d. repeating a sequence of instructions
17. An advantage of a custom block is:
a. it creates more work.
b. it makes programming harder.
c. it can condense a number of blocks into one block.
d. it takes longer to code the application.
18. A variable’s data type
a. changes as the program executes
b. determines the kind of operations may be performed on the variable
c. determines the type of comment that can be included in the variable’s documentation
d. none of the above
19. The features required in an application are listed in which stage?
a. Debugging and testing
b. Application design
c. Application evaluation
d. Application requirements
20. Storyboards are created in which stage?
a. Design
b. Evaluation
c. Requirements
d. d. Development
21. The programming construct ITERATION refers to:
a. performing an action if a certain condition is true
b. comparing the values in two variables
c. branching from one part of a program to another
d. repeating a sequence of instructions

4
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

22. With respect to an object in a program, a METHOD is


a. A function associated with the object that implements the object’s behaviour
b. An attribute pf the object that can be used to store information associated with the object
c. A procedure used by the programmer to construct the object
d. The way an object is described in programming documentation
23. Which of the following statements is true of logic error:
a. It is caused by misuse of logic when coding the program that leads the program to produce
unintended or undesired output or other behaviour
b. It is caused by the code written not conforming to the syntax of the programming language
being used
c. It can be detected by compiler
d. None of the above
24. Branching constructs in programming allow for:
a. sequential and orderly execution for the portion of code within the construct.
b. selective execution or skipping certain portions of code in a program
c. repetition of the portion of code within the construct.
d. none of the above
25. In high level programming languages, an interpreter...
a. reads individual statements of a program, analyses and then executes them
b. generates codes automatically
c. converts the whole set of codes to machine language so that it can run
d. corrects errors made by the programmer
26. A validation rule of “ > 0 And < 10 “ means that
a. Input must be larger than 0
b. Input must be less than 10
c. Input must be larger or equal to 0 and less than 10
d. Input must be larger than 0 and less than 10
27. Why is modularisation an important programming technique?
a. Because it provides separation of concerns, and improves maintainability by enforcing
logical boundaries between components
b. Because it enforces programmer to document the software
c. Because it improves the performance of a program
d. All of the above

5
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

28. Why is a syntax error relatively easier to identify compared with a logic error?
a. It is because a syntax error would not affect the functionalities of a program and can often
be ignored
b. It is because a logic error can be recognized by compiler at compilation time while
identifying a syntax error can potentially involve comparing all the possible results
generated by the program against the expected results
c. It is because a syntax error can be recognized by a compiler at compilation time while
identifying a logic error can potentially involve comparing all the possible results generated
by the program against the expected results.
d. None of the above
29. Which programming construct should be used if portions of code need to be selectively executed
or skipped based on certain condition(s)?
a. Sequence construct
b. Branching construct
c. Repetition construct
d. Exception construct
30. In the following pseudocode, what is the value of the variable index at the end of the procedure?
set number1 to 1
set index to 1
repeat until index > 5
set index to index + number1

a. 1
b. 4
c. 5
d. 6
31. Referring to the pseudocode in Question 18, what is the value of the variable number1 at the end
of the procedure?
a. 1
b. 4
c. 5
d. 6

6
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

33. In programming, a loop allows for the


a. sequentially and orderly execution of a portion of code within a program
b. selective execution of certain portions of code in a program
c. repetition of a portion of code within in a program
d. skipping of certain portions of code in a program
34. In Scratch, a Sprite is
a. an object/character that can move on the Stage
b. an object/character that can be controlled by scripts
c. used to perform arithmetic and logical instructions
d. a & b
35. Which of the following is not a comparison operator:
a. +
b. >
c. <
d. =
36. What is the purpose of using the backpack in Scratch?
a. To allow the sprites to converse with each other in a seamless manner.
b. To store assets such as blocks to be dragged and dropped between applications.
c. To change backdrops to allow the user to advance to a new level in a game application.
d. To add a variable to keep track of a score of a player in a game application.
37. The following are Events in Scratch except:
a. When green flag clicked
b. When space pressed
c. Broadcast message
d. Wait for 1 sec

7
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

39. When the following pseudocode is executed with variables Age and NewAge in the Scratch
pseudocode below, what is the result displayed for a user who is 17?

a. Next birthday you will be 17


b. Next birthday you will be 18
c. Next birthday you will be17
d. Next birthday you will be18
40. In Scratch programming, it is not possible to have the following errors:
a. Runtime errors
b. Syntax errors
c. Logic errors
d. All of the above
41. A Boolean data type can store
a. Text
b. True
c. False
d. True or False

8
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

Sally create the following script in scratch.

42. The line of script is an example of data validation


Data Validation helps to
a. Reduce the chance of correct data being output
b. Reduce the chance of incorrect data being input
c. increase the chance of incorrect data being input
d. test the application to check if all functions are working correctly
43. Which is the best set of test data to test the validation rule?
a. 0, 1, 199,200
b. 0, 1, 200, 201
c. 1, 2, 198, 199
d. -1, 0, 200, 201
44. A variable used in the script above is
a. Score
b. Age
c. 200
d. If Then Else
45. An operator used in the code above
a. 0
b. <
c. Age
d. +

46. is an example of which programming construct?


a. List
b. Sequence
c. Iteration or repetition
d. Condition or selection

9
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

47. Below is a script from a Scratch application. What type of shape will be drawn after the script is
executed

a. Square
b. Triangle
c. Rectangle
d. Circle
48. ____________ is a software that is used to create a series of instructions that will control the
behaviour of a computer
a. Instructions
b. Programming language
c. System Software
d. Application Software
49. __________________ is a series of connected instructions or blocks
a. Blocks
b. Scripts
c. Functions
d. Iteration

10
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

50. Below is a script from a Scratch application. What type of shape will be drawn after the script is
executed

a. Square
b. Triangle
c. Rectangle
d. Circle
51. Below is a script from a Scratch application. What type of shape and colour will be drawn after
the script is executed

11
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

a. Rectangle
b. Red Square
c. Red Rectangle
d. Circle
52. Identify the type of event used in Question 51
a. When this sprite is clicked
b. When flag clicked
c. When I receive move
d. When backdrop switch to Shapes
53. Identify the category of blocks used in the Question 51
a. Events, Motion, Pen
b. Iteration, Sequence, Selection
c. Motion and Pen
d. Events, Motion, Pen, and Control
54. ____________________ is a group of instructions can be combined into single custom block
which save time and effort
a. Functions
b. Scripts
c. Block
d. Stage
55. When the following pseudocode is executed
When green flag is clicked
Set X to 5
Set X to X + 1
Set Y to X + 3
Say Y
The value stored in the variable Y will be
a. 0
b. 5
c. 8
d. 9

12
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

56. Below is the script from a Scratch Application. What will be the result of the following script if the
number 5 is entered?

a. 5
b. 20
c. 15
d. 10
57. Below is the script from a Scratch Application. What is the value of final value of counter and
results

a. 5 and 15
b. 10 and 5
c. 15 and 5
d. 15and5

13
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

58. Below is the script from a Scratch Application. What is the value of final value of x and y

a. 31 and 12
b. 31,12
c. 12 and 31
d. None of the above
59. ______________ is a single line of code which instructs CPU to perform task in Scratch, blocks
are used.
a. Internal documentation
b. Instruction
c. Stage
d. Backdrop

14
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

61. Below is the script from a Scratch Application. What is the value of final value of a and i

a. 7, 5
b. 5 and 7
c. 5,7
d. 7 and 5

15
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

63. Below is the script from a Scratch Application. What is the value of final value of a

a. 11
b. 21
c. 20
d. 5

16
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

64. Below is the script from a Scratch Application. What is the value of final value of a

a. 25
b. 20
c. 35
d. 50

17
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

66. Below is the script from a Scratch Application. What is the value of final value of a

a. 26
b. 21
c. 35
d. 20
67. A single environment where all the development of an application occurs
a. Integrated Development Environment (IDE)
b. Internal Documentation
c. Function
d. Scripts
68. A sprite is an object that can move. A sprite can also be re-sized, unlike a backdrop.
a. True
b. False

18
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

70. Most applications will have at least one sprite.


a. True
b. False
71. Blocks can be selected from the blocks palette
a. True
b. False
72. A block is an instruction.
a. True
b. False
73. Blocks have been organised into 10 groups
a. True
b. False
74. Each block in a group will have the same colour.
a. True
b. False
75. ____________________ is a programming language model organised around objects rather than
the actions and data rather than logic
a. Object-oriented methodology
b. Object-Oriented programming
c. Object-oriented model
d. Low level language
76. Scripts are created in
a. Backdrop
b. Block Platte
c. Script Area
d. Sprite Area
77. Which control structure executes instructions in the order that they are written?
a. Selection
b. Sequence
c. Assignment
d. Iteration

19
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

Use the following pseudocode to answer questions 74 to 78


Below is the script for an application

78. Identify the output produced by the application if the test data of 100 was input.
a. Weight
b. Weight out of range.
c. You are a healthy weight.
d. You are a very healthy weight.
79. Which of the following lines of code in the pseudocode contains an operator?
a. Else
b. Input Weight
c. If Weight > 100 Then
d. Print “You are a very healthy weight”

20
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

80. Which type of control structure is used in the application?


a. Sequence and Selection
b. Sequence and Iteration
c. Selection and Iteration
d. Sequence, Selection and Iteration
81. Which is the best set of test data to test the validation rule below?

a. -1, 0, 1, 999, 1000,1001


b. 1, 999
c. 0, 1, 999, 1000
d. 100,101
82. Which is the best set of test data to test the validation rule below?

a. -1, 100, 101


b. 99,100,101
c. 100, 101
d. All of the above
83. Scratch is a
a. Visual programming language
b. Programming language
c. Design Application
d. Console Application
84. The relationship between blocks and scripts
a. A block a set of instructions and a script is an instruction
b. A block is a single instruction and script is a collection of blocks
c. A block is a single word and script is a collection of words
d. All the above
85. A complete Scratch program is known as
a. Project
b. Application
c. Project or Application
d. None of the above

21
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

86. The figure below shows

a. A conversation between two sprites


b. A conversation between user and sprite
c. A conversation between user and user
d. None of the above
87. A custom block is a block that the user creates themselves. Custom blocks allow a number of
blocks to be compressed into a single block.
a. True
b. False
88. ______________ are comments that are added to the code. The purpose of the comments is to
explain how the script works.
a. External documentation
b. System documentation
c. Internal documentation
d. User documentation

22
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

Structured Questions

1. A program is created to accept input and display the Name and YearOfBirth and Gender of
a student. The input into this program should be validated.
For example, Name might be entered as “John Doe”, YearOfBirth might entered as 1998
and Gender might be entered as “M”.
a. What is the importance of validation in programming?
Validation only allows data defined to be input into a program. This is to ensure
accuracy and consistency for any of various kinds of user input in a program.
b. Give an example of how validation can be done in the above program.
Validation can be done on Gender, ie-to only accept “M” or “F” as input OR
Validation can be done on YearOfBirth, ie- to only accept numeric values and no leading
zeros
[2 marks]
2. In Scratch, when the sprite called Cat is clicked, the Cat is made to repeatedly move 5 steps
forward and 5 steps backward 100 times and then say “That’s tiring”.
a. Write the Scratch codes to achieve the above (using iteration).
[5 marks]
When Cat is clicked
Repeat 100 times
Move 5 steps
Move -5 steps
End repeat
Say “That’s tiring”
or
When Cat is clicked
Repeat 100 times
Change x by 5
Change x by -5
End repeat
Say “That’s tiring” and wait
c. Explain how the iteration works.
Iteration (Repeat in the pseudocode) above is used to repeat a sequence of
forward and backward steps 100 times

[2 marks]

3. Determine the value stored in variable x and variable y at the end of the execution of these
scripts.
set x to 4
set y to 2
repeat until y =0
set x to x-1
set y to x-2

Variable x = 2
Variable y = 0

23
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

[2 marks]
4. Determine the output at the end of the execution of these scripts.
set b to 10
set a to 20
set b to b + a
if a * 4 > b * 2 Then
say b
else
say a
Output = 30
[2 marks]
5. Why are variable types important in programming? Explain your answer with examples to
support your explanation.
Variable types are used to represent different entities or types of input/output values and
what operations can be performed on them.
Text or string variable type could represent people or places (eg-Name, City);
Numeric variable type could represent a numeric value which may be used in calculations
(eg-Radius, Width, Length, Score);
Boolean variable type can be used to represent a logical state of True or False
(eg-HasWonGame, IsFull)
[2 marks]
1. List and briefly describe the Project Stages
Application requirements – programmer will list out what must be included in an
application. This acts as a checklist of things to do.
Application design – programmer will design and plan how the application will function.
This includes the purpose of the application, the assets required, how they function and
a stage storyboard.
Application development – programmer will use a programming language (eg Scratch) to
create (or develop) the application based on the planned design. The application is also
tested and all errors are debugged.
Application evaluation – programmer will create an evaluation report to explain if all of
the application requirements are met and how the requirements were achieved.
[6 marks]
9. Describe the three types of programming errors with examples?

Syntax errors are caused by the code written not conforming to the syntax of the programming
language being used. It can be recognized by compiler at compilation time. Example: If the
programming code is <Repeat until> and the programmer types <Repeat uptil> instead
Logic errors are caused by misuse of logic when coding the program that leads the program to
produce unintended or undesired output or other behaviour.
Example: the expected output should display the area of a circle, but the actual output displays
the circumference of a circle
Run-time errors are those that appear only after you compile and run your code.
These involve code that may appear to be correct in that it has no syntax errors, but
that will not execute.
Example: division by zero

24
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

[6 marks]
10. Trace the following lines of Scratch codes and fill in the values of the variables in the tables below
when these codes are executed.
1 set z to 3
2 set y to 1
3 set x to 2
4 repeat until x > 15
5 change x by 3
6 set z to x + y
7 set y to z + 2
VARIABLES
Lines executed
x y z
1, 2, 3 2 1 3
4-7
5 8 6

4-7
8 18 16

4-7
11 31 29

4–7
14 47 45

4-7
17 66 64

Variable values at the end


17 66 64
of execution:
[5 marks]

11. Identify and define the script above


A custom block is a block that the user creates themselves. Custom blocks allow a number of
blocks to be compressed into a single block.
a. Explain the script above
An event: When green flag clicked
A custom block: define jump
A Control block: wait 1 secs
A Motion block: move 20 steps OR change y by how far OR change y by 0 – how
far
An Operators block: 0 – how far

25
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

b. Discuss an advantage of using the script above


Advantages
Reduces the number of blocks needed to create an application
Save time and efforts when the same block needs to be used over and over again
[1 + 2 + 1 marks]
12. Logic error is an example of an error in a computer program.
a. What are logic errors in a program?
Logic errors are caused by misuse of logic when coding the program that leads the
program to produce unintended or undesired output or other behaviour.
OR
Logic errors can be identified when the actual output differs from the expected output.
b. Why are logic errors the most difficult type of error to detect?
Unlike syntax errors, the only indication of a logic error is the production of
incorrect/undesired output/results.
[2 marks]
13. How can a programmer detect logic errors in a program?
Logic errors can be detected by creating a test plan to check if the actual output differs from
the expected output.
[2 marks]
14. Trace the following lines of Scratch codes and fill in the values of the variables in the tables below
when these codes are executed.
1 set bob to true
2 set cat to 10
3 set x to 2
4 repeat until cat > 20
5 change cat by 2
6 set x to x + cat
7 change x by 1
8 if cat < x Then
9 set bob to false
10 set cat to cat + 4
11 else
12 set bob to true
13 set cat to cat + 2

VARIABLES
Lines executed
bob cat x
1, 2, 3 true 10 2

false 12,16 14,15

false 18,22 33,34

Variable values at the end


false 22 34
of execution:
[6 marks]

26
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

15. What are programming languages? Give an example of a low-level programming language and an
example of a high-level programming language.
Programming languages are tools used by programmers to create software/applications/programs.
Example of low-level programming language: Assembly language, machine language
Example of high-level programming language: Scratch, VB.net, Java
[2 marks]
10. How are low-level and high-level programming languages different in terms of complexity and
portability?
Low-level programming languages (such as machine language/assembly language) consists of
codes which are complex and difficult to understand and are less portable (machine
dependent). High-level programming languages (such as Scratch/VB.net) are less complex and
easier to understand as they consist of short English-like statements and are portable (machine
independent)
[2 marks]
11. Explain the difference between non-array variables and lists (arrays). Provide an example of a
programming situation where a list (array) would be appropriate.
A variable (non-array) holds a single data item (eg- Score, Name, Area) whereas a list (array) holds
multiple data items (eg- ListOfPlayers, HighScoreHistory).
A situation where a list (array) would be appropriate is when operations to be performed
include adding, updating and removing items.
[3 marks]
12. List and briefly describe the three core constructs of a computer program

Sequence - The control structure sequence occurs when each instruction (or block) is executed
one after the other, in the order that they appear in the Scripts Area.
Iteration / Repetition / Looping - The control structure repetition executes instructions over and
over again.
Selection / Branching / Decision - The control structure selection allows instructions or blocks
to be executed only if a condition is true.
[3 marks]
13. Outline the purpose of backdrop in Scratch
A backdrop is an image to be added to the stage.

Limitation- Backdrops cannot move and they also cannot be resized.

[3 marks]
14. Outline the purpose of sprite in Scratch
A sprite is an object that can move. A sprite can also be re-sized, unlike a backdrop.
[3 marks]
15. Describe TWO differences between backdrop and sprite
Backdrops cannot move
Backdrop cannot be resized
A sprite can be moved and resized
[3 marks]
16. Outline what us the purpose of stage

27
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

The stage is the canvas or background of the application.


When the application is executed (e.g. the green flag is clicked) only the stage area is visible to the
user. Images can be used as a backdrop of the stage.
[3 marks]
17. Define what is scripts and what is the purpose of scripts
Definition - A script is a collection of blocks that provide a series of instructions that need to be
executed.
Purpose-Scripts are used with sprites to control how the sprite interacts with other objects. Scripts
can also be used with backdrops.
[3 marks]
18. Define the repetition control block. Briefly explain three example of repetition block
The control structure repetition executes instructions over and over again.
The blocks that use repetition include:

 Repeat

All of the instructions within the repeat block will be executed in the order shown, by the
number of times indicated in the repeat block.
Example
When green flag clicked
Repeat 4
Move 10 steps
Turn 90 degrees

 Repeat until

Similar to the Repeat block the instructions within a ‘Repeat until’ block will execute over
and over again. But unlike a repeat block, the number of times the instructions are
repeated is based on a condition, not a fixed number.

Example

When green flag clicked

Set a to 1

Set b to 2

Repeat b > 6

Set a to a + b

Set b to a + b

Say a and b for 2 seconds

28
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

 Forever

Blocks within the forever block are executed over and over again as long as the project is
running.

When green flag clicked


Forever
Move 10 steps
Turn 90 degrees
[4marks]
You were asked to create an application with the following requirements
• User input customer’s name and age
• If the age is at least 21 then print – You are eligible to vote.
• If the age less than 21 then print – Too Young. You are not eligible to vote.
You have created the script for the application. This script is shown below

a. Define the term control structure


A control structure relates to the order in which instructions (blocks) are executed.
[1 mark]
b. Describe, using examples, the different control structures used in the script above.
Sequence - The control structure sequence occurs when each instruction (or block) is
executed one after the other, in the order that they appear in the Scripts Area.
Example from the script above
When green flag clicked

Ask name and wait

Set name to answer

29
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

Ask Age and wait

Set Age to Answer

Selection / Branching - The control structure selection allows instructions or blocks to be


executed only if a condition is true.

If Age > 21 then

Say “Hi there” Name for 2 seconds

Say “You are eligible to vote”

Stop All

Else

Say “Hi there” Name for 2 seconds

Say “Too young. You are not eligible to vote”

Stop All

[4 marks]
c. Identify the operators used in the script above. Explain the purpose of the operator
IF Age >21 Then

Join “Hi there” Name

Operators are blocks that are mainly used to allow mathematical equations to occur within
a project, while some allow text manipulation.
[3 marks]
d. Explain the purpose of variable in programming. Give an example of block that contains a
variable
Variable is a container (or box) that is used to store data. The value stored in the variable can
change as an application is running. You can make a variable in the Data Scripts group.
[3 marks]
e. List the block in your script that contain the variable
Set Name to Answer

Set Age to Answer

IF Age > 21 then

[3 marks]
f. List and describe one block that was used to create the conversation in between the Scratch Cat
and User
Ask … and wait
Say Block
Ask .. and wait provide a textbox that allows users to enter a text to be accepted and the Say
block provides a speech bubble that allows text to be displayed that appears to be spoken by
the sprite

30
MUF0051 ICT UNIT 1 REVISION MANUAL SA2 – SCRATCH PROGRAMMING

[3 marks]
You realise that your script contains error

g. Identify the type of error your script produces


Logic Error
[3 marks]

When you enter 22 you realise that the program displays the greeting Hi There <name> and not the
message “You are eligible to vote”

h. Identify the problem and suggest a correction


Problem
For “Age >21” condition, the second “Say “block does not have a “for x seconds” section. That
is why the messages is not displayed
Correction
Include the block “Say… for x seconds”.
[3 marks]
After correction the script for part (d) You realise that when you enter 21 you realise that the
program displays the greeting Hi There <name> and message “Too young. You are not eligible to
vote”

i. Identify the problem and suggestion a correction


Problem
For the condition is “Age > 21” this does not include 21, That is why an incorrect output is
received
Correction
Change the condition to Age > 21 or Age = 21
(NOTE! DO NOT USE Age > 20 / Age >= 21)
[3 marks]

31

You might also like