Functions In Python: MCQs on Functions in Python Language

Functions MCQs in Python Programming.

 

Functions In Python

 

 

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

def change(one, *two):
print(type(two))
change(1,2,3,4)

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

 

Lambda contains block of statements ??

a) True
b) False

 

What will be the output of the following ??

def change(i = 1, j = 2):
i = i + j
j = j + 1
print(i, j)
change(j = 1, i = 2)

a) An exception is thrown because of conflicting values
b) 1 2
c) 3 3
d) 3 2

 

Lambda is a statement ??

a) True
b) False

 

What will be the output ??

a=10
b=20
def change():
global b
a=45
b=56
change()
print(a)
print(b)

a) 10
56

b) 45
56

c) 10
20

d) Syntax Error

 

Does Lambda contains return statements ??

a) True
b) False

 

What will be the output of the following Python ??

def a(b):
b = b + [5]
c = [1, 2, 3, 4]
a(c)
print(len(c))

a) 4
b) 5
c) 1
d) An exception is thrown

 

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

lamb = lambda x: x ** 3
print(lamb(5))

a) 15
b) 555
c) 125
d) None of the mentioned

 

What will be the output ??

i=0
def change(i):
i=i+1
return i
change(1)
print(i)

a) 1
b) Nothing is displayed
c) 0
d) An exception is thrown

 

What will be the output of the following ??

y = 6
z = lambda x: x * y
print z(8)

a) 48
b) 14
c) 64
d) None of the mentioned

 

What is a variable defined inside a function referred to as ?? 

a) A global variable
b) A volatile variable
c) A local variable
d) An automatic variable

 

Python supports the creation of anonymous functions at runtime, using a construct called ??

a) lambda
b) pi
c) anonymous
d) none of the mentioned

 

What is a variable defined outside a function referred to as ??

a) A static variable
b) A global variable
c) A local variable
d) An automatic variable

 

Read More

Leave a Comment

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

error: Content is protected !!