wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Functions and Method

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which keyword is used for function?

a)

define

b)

fun

c)

def

d)

function

2.

Which of the following items are present in the function header?

a)

function name

b)

parameter list

c)

return value

d)

Both A and B

3.

What is called when a function is defined inside a class?

a)

class

b)

function

c)

method

d)

module

4.

If the return statement is not used inside the function, the function will return:

a)

None

b)

0

c)

Null

d)

Arbitary value

5.

What is a recursive function?

a)

A function that calls other function.

b)

A function which calls itself.

c)

Both A and B

d)

None of the above

6.

Which of the following function headers is correct?

a)

def fun(a = 2, b = 3, c)

b)

def fun(a = 2, b, c = 3)

c)

def fun(a, b = 2, c = 3)

d)

def fun(a, b, c = 3, d)

7.

In which part of memory does the system store the parameter and local variables of a function call?

a)

heap

b)

stack

c)

Uninitialized data segment

d)

None of the above

8.

How is a function declared in Python?

a)

def function function_name():

b)

declare function function_name():

c)

def function_name():

d)

declare function_name():

9.

Which one of the following is the correct way of calling a function?

a)

function_name()

b)

call function_name()

c)

ret function_name()

d)

function function_name()

10.

Which of the following functions is a built-in function in python?

a)

array()

b)

sqrt()

c)

factorial()

d)

print()

11.

What will be the output of the following Python function?

all([2,4,0,6])

a)

Error

b)

True

c)

False

d)

0

12.

What will be the output of the following Python expression?

round(4.5676,2)

a)

4.5

b)

4.6

c)

4.57

d)

4.56

13.

What will be the output of the following Python function?

any([2>8, 4>2, 1>2])

a)

Error

b)

True

c)

False

d)

4>2

14.

What will be the output of the following Python function?

min(max(False,-3,-4), 2,7)

a)

2

b)

False

c)

-3

d)

-4

15.

What is the order of precedence in python?

i) Parentheses

ii) Exponential

iii) Multiplication

iv) Division

v) Addition

vi) Subtraction

a)

i,ii,iii,iv,v,vi

b)

ii,i,iii,iv,v,vi

c)

ii,i,iv,iii,v,vi

d)

i,ii,iii,iv,vi,v