wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Function

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

Name the keyword used to define a function.

a)

define

b)

def

c)

function

d)

fu

2.

def square(x) (a)  

print(x*x)

3.

Which one is not true about function?

a)

It breaks the large program into small modules.

b)

It avoids repetition.

c)

It makes code reusable.

d)

It makes the program unorganized.

4.

Which statement is used to display the docstring?

a)

print(welcome.__doc__)

b)

print(__doc__)

c)

print(welcome._doc_)

d)

print(docstring)

5.

What is the value of Y?

a)

Error

b)

None

c)

Alsan

d)

Hello, Alsan Good Morning!

6.

Which one is incorrect calling function statement?

a)

add(4, c = 10, b = 5)

b)

add(3, 4, c = 45)

c)

add (b = 12, c = 10, 1)

d)

add (5, 6, 7)

7.

What will be the output?

a)

Value inside function: 10

Value outside function: 20

b)

Value inside function: 10

Value outside function: 10

c)

Value inside function: 20

Value outside function: 10

d)

Value inside function: 20

Value outside function: 20

8.

What is the output?

a)

Value inside function: 10

Value outside function: 20

b)

Value inside function: 10

Value outside function: 10

c)

Value inside function: 20

Value outside function: 20

d)

Value inside function: 20

Value outside function: 10

9.

def add(x,y):

return x+y

a = 5

b = 10

add(a,b)

Name the actual parameters.

a)

a,b

b)

x,y

c)

a,x

d)

b,y

10.

def add(x,y):

return x+y

a = 5

b = 10

add(a,b)

Name the formal parameters.

a)

a,b

b)

x,y

c)

a,x

d)

b,y

11.

What will print ?

a)

cats eat mice

b)

mice get away

c)

unknown

d)

error message