wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Function Review

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Choose the INVALID Function name

a)

def _output():

b)

def output_():

c)

def OUT_PUT9():

d)

def 9OUTPUT():

2.

In declaring a function, a number of parameters is always required.

a)

True

b)

False

3.

Select the correct description of the output

a)

The output is "4" because the parameter "a" is increased by 1

b)

The script is error

c)

No output

d)

"None" will be printed in the console

4.

The parameter is optional in defining a function. But if there are parameters, it should be up to ten (10) only.

a)

True because it will crash the memory if the parameters are more than 10.

b)

True because it is part of the syntax in declaring a Python function.

c)

False because the declaration of the number of parameters has no limit.

d)

False because the limit is up to twenty (20).

5.

Describe the output of the Python script

a)

The script is error because you cannot perform arithmetic operations in a return statement

b)

The script is error because the function must be defined first before calling it

c)

"None" will be displayed in the console since the function is declared after calling it

d)

"3" is the output because 2 is passed to the output() function and return (2+1)

6.

Is the code error?

a)

Yes, because you cannot return a function in line 2

b)

Yes, because you should call these functions after defined.

c)

No, the code works well.

7.

What is the correct syntax for creating a function in Python?

a)

def a():{}

b)

def a(x,y,z):

c)

def a(x){}

d)

def a(){}

8.

How do you call the "output" function?

a)

output(2,1):

b)

output{1,2}

c)

output<1,2>

d)

output(2,1)

9.

What is the output of the script?

a)

None

b)

No output. The code is error!

c)

X

d)

Y

10.

How do you call the update() function to print "Middle" in the console?

a)

print(update(6))

b)

update(7)

c)

print(update(5))

d)

update(5)