Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

09-Subroutines-GCSE-Python

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the primary purpose of a subroutine in programming?

a)

To execute the main program

b)

To provide a set of instructions that can be called upon separately from the main program

c)

To enhance the graphical user interface

d)

To connect to the internet

2.

What is the difference between a procedure and a function in programming?

a)

A function returns a value back to the main program after execution, while a procedure does not

b)

A procedure returns a value back to the main program after execution, while a function does not

c)

A function is used only in Java, while a procedure is used only in Python

d)

A procedure is used to terminate the program, while a function is not

3.

What does 'parameter passing' refer to in the context of subroutines?

a)

Passing control to different parts of the program

b)

Sending arguments to subroutines to use during their execution

c)

The process of exiting a subroutine and returning to the main program

d)

The method of looping through data within a subroutine

4.

What is one of the primary benefits of using subroutines in programming?

a)

Reduces program size

b)

Increases processing speed

c)

Removes repeating code

d)

Enhances color scheme

5.

Which of the following is NOT a benefit of using subroutines as mentioned in the text?

a)

Allows for easier debugging

b)

Improves the overall organization of the program's logic

c)

Simplifies user interface design

d)

Provides a structured approach to programming

6.

What problem do subroutines help to solve when programming large applications?

a)

Difficulty in finding errors and editing code

b)

Lack of programming languages

c)

Insufficient data storage

d)

Low network bandwidth

7.

What is a subroutine in programming?

a)

A block of code with a unique name that executes when called

b)

A unique type of variable used to store data

c)

A method to debug programs

d)

A data structure used to organize information

8.

What happens to the main program when a subroutine is called?

a)

The main program continues to execute other functions

b)

The main program terminates

c)

The main program pauses until the subroutine has finished executing

d)

The main program skips the subroutine execution

9.

Which computational thinking strategies can be directly linked to use of subroutines?

a)

Decomposition and Abstraction

b)

Pattern Recognition and Algorithm Design

c)

Simulation and Evaluation

d)

Breaking into sperate calls

10.

What is the main difference between a function and a procedure in programming?

a)

A function can execute faster than a procedure.

b)

A procedure can return values, but a function cannot.

c)

A function will return values back to the main program after it has been called, whereas a procedure will not.

d)

A procedure is used only in Python, while a function is used in all programming languages.

11.

What is the command used to declare a procedure in Python?

a)

procedure

b)

function

c)

def

d)

declare

12.

What must follow the procedure name when defining it in Python?

a)

A semicolon

b)

A colon

c)

A comma

d)

A period

13.

What is a local variable in programming?

a)

A variable defined outside any subroutine or function

b)

A variable defined within a subroutine or function

c)

A variable that can be accessed anywhere in the program

d)

A variable that is only used in main programs

14.

What is the scope of a global variable?

a)

It can only be accessed within the subroutine it is defined in

b)

It can only be accessed within the block it is defined in

c)

It can be accessed anywhere in the program

d)

It cannot be accessed at all

15.

What happens if a subroutine does not assign its own local variable?

a)

It cannot use any variables

b)

It will create a new global variable

c)

It will use a global variable if available

d)

It will result in a runtime error