wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Procedure & Functions

Total questions: 16

Worksheet time: 10mins

Name
Class
Date
1.

What is a Subroutine?

a)

a block of code that performs a specific task

b)

A long piece of code that does not use indentation

c)

A type of iteration

d)

a block of code named def

2.

When creating a subroutine, when we have values placed in the brackets, what is this called?

e.g. def sub1(data1, data1) :

a)

parameter

b)

argument

c)

var

3.

Tick the advantages of using subroutines

a)

Allows you to break the code down into chunks

b)

easier to read and maintain

c)

•Easier to debug as errors are easier to spot as they are contained into the subroutines

d)

Allows you to test them independently

e)

•Allows you to add in lots of repeated code to the program

4.

Leo wants to create a subroutine that will roll a dice. Which syntax is correct?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

5.
Which of the following best describes the order in which these lines are processed in Python?
a)
4, 1, 2
b)
4, 2, 1
c)
1, 2, 3, 4
d)
3, 1, 2
6.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
7.

The subroutines must be defined BEFORE the main program is written.

True or False?

a)

True

b)

False

8.

Which subroutine does not return any data?

a)

Condition

b)

Loop

c)

Procedure

d)

Function

9.

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

a)

def

b)

procedure

c)

function

d)

proc

10.

Does your subroutine code require indentation?

a)

Yes

b)

No

c)

Sometimes

11.

Using "meaningful identifiers" means...

a)

Giving variables and subroutines sensible names

b)

Giving variables the correct data type

c)

Correct use of conditions in loops

12.

What is the term for a named block of code that can be executed by writing its name.

a)

Subroutine

b)

Condition

c)

Selection

13.

What are the parameters with in this procedure?

a)

first name and second name

b)

first and surname

c)

first and second name

d)

myname, first and surname

14.

What happens if you call a subroutine before defining it in Python?

a)

The program will crash

b)

The subroutine will be activated

c)

The computer will look for the subroutine and not find it

d)

The program will continue without any issues

15.

Can a subroutine have multiple parameters?

a)

No, a subroutine can only have one parameter

b)

Yes, a subroutine can have as many parameters as needed

c)

Yes, but there is a limit to the number of parameters

d)

No, a subroutine cannot have any parameters

16.

How should subroutines be structured in Python?

a)

All subroutines should be placed at the top of the code

b)

Subroutines should be called before they are defined

c)

Subroutines should have the same name as the main program

d)

Subroutines should be indented using spaces