Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python functions

Total questions: 25

Worksheet time: 19mins

Name
Class
Date
1.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
2.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
3.
What will print?
a)
nothing
b)
7
c)
z
d)
12
4.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
5.
What will print?
a)
1 2
b)
1
c)
3
d)
5
6.

What term is used to describe data passed into a function?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

7.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

8.

Write the line of code that will call the function.

(a)  

9.

Write the line of code that will define the function, draw_coin

(a)  

10.

Do you call or define a function first?

a)

call

b)

define

11.

Correctly rewrite this line of code!

(a)  

12.

Correctly rewrite this line of code !

(a)  

13.

Rewrite the line of incorrect code using Camel Case to make it correct!

Hint: The mistake is when the function gets called

(a)  

14.
What will print ?
a)
cats eat mice
b)
mice get away
c)
unknown
d)
error message
15.
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
16.
What will print?
a)
nothing
b)
sayHi()
c)
an error message
d)
hi there
17.
What will print?
a)
5
b)
6
c)
3 2
d)
an error message
18.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
19.
What will print?
a)
4
b)
5
c)
nothing
d)
an error message
20.
What will print?
a)
4
b)
5
c)
7
d)
an error message
21.

What is the output of the given code?

a)

10 20 10

b)

10

c)

20

d)

10 20

22.

Select the advantages of functions

a)

Modular programming

b)

Code re-usability

c)

Improving clarity of the code

d)

All the above

23.

The parameters could be a

a)

Variable

b)

Literal

c)

Expression

d)

Function

24.

What will be the output of this program?

a)

0

b)

1

c)

2

d)

3

e)

4

25.

The process of creating a function is as follows

1. Use the keyword def to declare the function

2. Follow with defining the function name

3. Add parameters to the function: they should be within the parentheses() of the function.

4. End this line with a colon after the parenthesis.

5. Indent and then add the statements that the functions should execute

6. Include a return statement if the function should output something. Without the return statement, your function will return an object  - None

What is missing from this function?

a)

return value statement

b)

Variable

c)

Function definition

d)

Parameters