WorksheetsY10 - Subprograms, Procedures, Functions
Total questions: 19
Worksheet time: 10mins
Definition of a subprogram
A sequence of instructions to perform a specific task with an identifiable name
Breaking down a problem into smaller more manageable chunks
Allows values to be passed into a function
Definition of a Function
A subprogram that executes a block of code when called. It does not return a value
A subprogram that returns a value
Used in a subprogram to allow values to be passed into them
Definition of a Procedure
The values held in the brackets of a subprogram call.
A subprogram that returns a value
A subprogram that executes a block of code when called. It does not return a value
Definition of a Parameter
Used when defining a subprogram to allow values to be passed into them
A sequence of instructions to perform a specific task with an identifiable name
The values held in the brackets of a program call.
Definition of an Argument
A subprogram that returns a value
Used when defining a subprogram to allow values to be passed into it
The values held in the brackets of a subprogram call
Definition of a return value
A value that is returned by a procedure
A value that is returned by a function
Used in a subprogram to allow values to be passed into them
Definition of Decomposition from Computational Thinking
Breaking down a problem into smaller subproblems to make the more manageable
Returning a return value from a function
Creating step by step instructions to perform a task or solve a problem
Subprograms are defined outside of the main program
True
False
Subprograms are defined below the main program
True
False
Is this a function or a procedure?
Function
Procedure
Is this a Function or a Procedure?
Function
Procedure
What is the difference between a Function and a Procedure?
A procedure returns a value whereas a function does not.
A function returns a value whereas a procedure does not
A function accepts parameters whereas a procedure only accepts arguments
Select the THREE facts about subprograms
Subprograms are called from the main program
Subprograms always return a value
When defining subprograms, values passed in are called parameters
When calling subprograms, values passed in are called arguments
Subprograms cannot be called from the main program
Which is the definition of an array
An array can only store a single value of a pre-defined data type
An array is a collection of elements that are all the same data type
An array is a collection of elements that can be a combination of data types
Give the name of the data structure that Python uses to implement arrays?
Variable
Array
List
Which is the correctly written code to store a return value from the subprogram 'YourName' into the variable 'name'
name = YourName
name = YourName()
YourName() = name
How do you initialise an empty list named 'shopping'?
shopping = { }
shopping = " "
shopping = [ ]
How do you initialise an empty string named 'item'?
item = " "
item = { }
item = [ ]
Correct way to use randint to create a random number between 1 and 6?
math.randint(1 to 6)
random.randint(1,6)
random.randint(1,2,3,4,5,6)
