wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Subroutines

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

What would the output be for the following program if the user enters 4 and 6?

a)

10

b)

14

c)

16

d)

error

2.

If the user inputs "Connolly"into surname and "Luke" into first what would be output?

a)

Error

b)

Connolly Luke

c)

Luke Connolly

d)

Connolly Luke Connolly Luke

3.

John wants to create a subroutine in python that will roll a dice. Which is the correct method below?

a)

DEFINE diceroll:INTEGER

b)

def diceroll[]:

c)

def diceroll():

d)

def diceroll:

4.

Norah wants to print her multiplication equation of 12 x 12. What code should she add below?

a)

print (multiply)

b)

a = 12

b = 12

answer = a * b

c)

print(multiply(12, 12))

d)

print(multiply(12 * 12))

5.

"Declaration" refers to...

a)

Storing data in variables

b)

Creating variables

c)

Repeating sections of code

d)

Checking a condition to see which piece of code to run next

6.

"Iteration" refers to...

a)

Storing data in variables

b)

Creating variables

c)

Repeating sections of code

d)

Checking a condition to see which piece of code to run next

7.

A loop within a loop is...

a)

Definite iteration

b)

Indefinite iteration

c)

Nested iteration

d)

Reverse Polish iteration

8.

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

9.

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

a)

Subroutine

b)

Condition

c)

Selection

10.

Some subroutines produce a result that is sent back to where they were called from. What is this value called?

a)

Return value

b)

Final value

c)

Parameter

d)

Variable

11.

Local variables...

a)

...only exist while their subroutine is executing

b)

...are only accessible in the subroutine in which they are declared

c)

...can only be of the 'integer' data type

d)

...can be used from anywhere in a program

12.

Which of the following is not an example of a subroutine?

a)

Procedure

b)

Function

c)

List

13.

Subroutines are designed to save the programmer time

a)

True

b)

False

14.

Which subroutine will return a value back to the program?

a)

Procedure

b)

Function

15.

Which subroutine will not return a value back to the program?

a)

Procedure

b)

Function

16.

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