Worksheets09-Subroutines-GCSE-Python
Total questions: 15
Worksheet time: 8mins
What is the primary purpose of a subroutine in programming?
To execute the main program
To provide a set of instructions that can be called upon separately from the main program
To enhance the graphical user interface
To connect to the internet
What is the difference between a procedure and a function in programming?
A function returns a value back to the main program after execution, while a procedure does not
A procedure returns a value back to the main program after execution, while a function does not
A function is used only in Java, while a procedure is used only in Python
A procedure is used to terminate the program, while a function is not
What does 'parameter passing' refer to in the context of subroutines?
Passing control to different parts of the program
Sending arguments to subroutines to use during their execution
The process of exiting a subroutine and returning to the main program
The method of looping through data within a subroutine
What is one of the primary benefits of using subroutines in programming?
Reduces program size
Increases processing speed
Removes repeating code
Enhances color scheme
Which of the following is NOT a benefit of using subroutines as mentioned in the text?
Allows for easier debugging
Improves the overall organization of the program's logic
Simplifies user interface design
Provides a structured approach to programming
What problem do subroutines help to solve when programming large applications?
Difficulty in finding errors and editing code
Lack of programming languages
Insufficient data storage
Low network bandwidth
What is a subroutine in programming?
A block of code with a unique name that executes when called
A unique type of variable used to store data
A method to debug programs
A data structure used to organize information
What happens to the main program when a subroutine is called?
The main program continues to execute other functions
The main program terminates
The main program pauses until the subroutine has finished executing
The main program skips the subroutine execution
Which computational thinking strategies can be directly linked to use of subroutines?
Decomposition and Abstraction
Pattern Recognition and Algorithm Design
Simulation and Evaluation
Breaking into sperate calls
What is the main difference between a function and a procedure in programming?
A function can execute faster than a procedure.
A procedure can return values, but a function cannot.
A function will return values back to the main program after it has been called, whereas a procedure will not.
A procedure is used only in Python, while a function is used in all programming languages.
What is the command used to declare a procedure in Python?
procedure
function
def
declare
What must follow the procedure name when defining it in Python?
A semicolon
A colon
A comma
A period
What is a local variable in programming?
A variable defined outside any subroutine or function
A variable defined within a subroutine or function
A variable that can be accessed anywhere in the program
A variable that is only used in main programs
What is the scope of a global variable?
It can only be accessed within the subroutine it is defined in
It can only be accessed within the block it is defined in
It can be accessed anywhere in the program
It cannot be accessed at all
What happens if a subroutine does not assign its own local variable?
It cannot use any variables
It will create a new global variable
It will use a global variable if available
It will result in a runtime error
