wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Test on Python Function

Total questions: 12

Worksheet time: 16mins

Name
Class
Date
1.
Which keyword is use 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 return statement is not used inside the function, the function will return:
a)
None
b)
0
c)
Null
d)
Arbitary value
5.
Which of the following is the use of function in python?
a)
Functions are reusable pieces of programs
b)
Functions don’t provide better modularity for your application
c)
you can’t also create your own functions
d)
All of the mentioned
6.
In which part of memory does the system stores the parameter and local variables of funtion call?
a)
heap
b)
stack
c)
Uninitialized data segment
d)
None of the above
7.
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():
8.
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()
9.
What will be the output of the following Python code? def sayHello():<br /> print('Hello World!') <br />sayHello() <br />sayHello()
a)
Hello World! Hello World!
b)
Hello World!' 'Hello World!'
c)
Hello Hello
d)
None of the mentioned
10.
What will be the output of the following Python code?def say(message, times = 1):<br /> print(message * times)<br />say('Hello')<br />say('World', 5)
a)
Hello WorldWorldWorldWorldWorld
b)
Hello World5
c)
Hello World,World,World,World,World
d)
Hello HelloHelloHelloHelloHello
11.
What will be the output of the following Python code? x = 50<br />def func():<br /> global x<br /> print('x is', x)<br /> x = 2<br /> print('Changed global x to', x)<br />func()<br />print('Value of x is', x)
a)
x is 50 Changed global x to 2 Value of x is 50
b)
x is 50 Changed global x to 2 Value of x is 2
c)
x is 50 Changed global x to 50 Value of x is 50
d)
None of the mentioned
12.
What will be the output of the following Python code? def func(a, b=5, c=10):<br /> print('a is', a, 'and b is', b, 'and c is', c) <br />func(3, 7)<br />func(25, c = 24)<br />func(c = 50, a = 100)
a)
      a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50
b)
12. a is 3 and b is 7 and c is 10 13. a is 5 and b is 25 and c is 24 14. a is 50 and b is 100 and c is 5
c)
16. a is 3 and b is 7 and c is 10 17. a is 25 and b is 5 and c is 24 18. a is 100 and b is 5 and c is 50
d)
None of the mentioned