Python Functions: MCQs on Functions in Python Language

Python Functions. Multiple Choice Questions on Python Functions. This section contains 10+ Multiple Choice Questions on Functions.

 

Python Functions

 

 

What will be the output of the following Python code ??

def sayHello():
print(‘Hello World!’)
sayHello()
sayHello()

a) Hello World!
Hello World!

b) ‘Hello World!’
‘Hello World!’

c) Hello
Hello

d) None of the mentioned

 

What are the two main types of functions ??

a) Custom function
b) Built-in function & User defined function
c) User function
d) System function

 

Which keyword is used for function ??

a) Fun
b) Define
c) Def
d) Function

 

Which are the advantages of functions in python ??

a) Reducing duplication of code
b) Decomposing complex problems into simpler pieces
c) Improving clarity of the code
d) All of the mentioned

 

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

 

What will be the output of the following Python code ??

def find(a, **b):
print(type(b))
find(‘letters’,A=’1′,B=’2′)

a) String
b) Tuple
c) Dictionary
d) An exception is thrown

 

What will be the output of the following Python code ??

min = (lambda x, y: x if x < y else y)
min(101*99, 102*98)

a) 9997
b) 9999
c) 9996
d) None of the mentioned

 

What will be the output of the following Python ??

def display(b, n):
while n > 0:
print(b,end=””)
n=n-1
display(‘z’,3)

a) zzz
b) zz
c) An exception is executed
d) Infinite loop

 

What will be the output of the following ??

L = [lambda x: x ** 2,
lambda x: x ** 3,
lambda x: x ** 4]
for f in L:
print(f(3))

a) 27
81
343

b) 6
9
12

c) 9
27
81

d) None of the mentioned

 

If a function doesn’t have a return statement, which of the following does the function return ??

a) int
b) null
c) None
d) An exception is thrown without the return statement

 

What will be the output of the following Python code?

def writer():
title = ‘Sir’
name = (lambda x:title + ‘ ‘ + x)
return name

who = writer()
who(‘Arthur’)

a) Arthur Sir
b) Sir Arthur
c) Arthur
d) None of the mentioned

 

What will be the output ??

def f(x, y, z): return x + y + z
f(2, 30, 400)

a) 432
b) 24000
c) 430
d) No output

 

Read More

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!