Worksheets8525 GCSE CS 3.2.10 Structured programming and subroutines
Total questions: 19
Worksheet time: 10mins
Using "meaningful identifiers" means...
Giving variables and subroutines sensible names
Giving variables the correct data type
Correct use of conditions in loops
What is the term for a named block of code that can be executed by writing its name.
Subroutine
Condition
Selection
Some subroutines produce a result that is sent back to where they were called from. What is this value called?
Return value
Final value
Parameter
Variable
Local variables...
(choose two answers)
...only exist while their subroutine is executing
...are only accessible in the subroutine in which they are declared
...can only be of the 'integer' data type
...can be used from anywhere in a program
Which of the following is not an example of a subroutine?
Procedure
Function
List
Subroutines are designed to save the programmer time
True
False
Which subroutine will return a value back to the program?
Procedure
Function
Which subroutine will not return a value back to the program?
Procedure
Function
What are the parameters within this procedure?
first name and second name
first and surname
first and second name
myname, first and surname
Which of the following is an advantage of using local variables?
They allow the variable to be used throughout the whole program
They allow variable identifiers to be reused each time
They are easier to program than global variables
A wider range of data types can be used
What term is used to describe data passed into/out of a program?
Variable
Loop
Constant
Parameter
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What is the difference between a subroutine and a function?
They are the same thing
A subroutine passes values back out to the program, a function does not
A function passes values back out to the program, a subroutine does not
A function can run without being called
Which of the following statements is not true?
Functions/subroutines are examples of reusable code
Functions and subroutines are always appropriate in programs
Using functions/subroutines make it easier to "deconstruct" a problem into smaller pieces
They can make programs easier to read and understand
What does this function do?
input()
Opens the CD tray.
Asks the user to type something in.
Displays the word 'input'.
Exits the program.
What is the name of the subroutine?
happyBirthday
person
def
What is the name of the parameter?
happyBirthday
person
def
A variable declared within a subroutine
Global
Local
A variable declared in the main program
Global
Local
