Vidyalelo
Python · all questions

Functions in Python
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

182

Questions

4/10

Page

Pick an option on a question to see the right answer and solution.

The output of the following codes are the same.
[x**2 for x in range(10)]
list(map((lambda x:x**2), range(10)))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = [12.1, 34.0]
print(len(' '.join(list(map(str, x)))))

Select an option to see the answer and solution.

What is the base case in the Merge Sort algorithm when it is solved recursively?

Select an option to see the answer and solution.

What will be the output of the following Python code?
x=100
def f1():
    global x
    x=90
def f2():
    global x
    x=80
print(x)

Select an option to see the answer and solution.

. . . . . . . . returns a dictionary of the module namespace.
. . . . . . . . returns a dictionary of the current namespace.

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x)))))

Select an option to see the answer and solution.

Which keyword is used for function?

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = ['ab', 'cd']
print(len(map(list, x)))

Select an option to see the answer and solution.

How can you define a function that accepts both positional and keyword arguments?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the output of the following code:
square = lambda x: x**2
result = square(5)
print(result)

Select an option to see the answer and solution.

What will be the output of the following Python code?
lamb = lambda x: x ** 3
print(lamb(5))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = [12, 34]
print(len(list(map(int, x))))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = ['ab', 'cd']
print(list(map(upper, x)))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
print(list(map([], x)))

Select an option to see the answer and solution.

What will be the output of the following Python code?
def f(x, y, z): return x + y + z
f(2, 30, 400)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 50
def func():
    global x
    print('x is', x)
    x = 2
    print('Changed global x to', x)
func()
print('Value of x is', x)

Select an option to see the answer and solution.

How many keyword arguments can be passed to a function in a single function call?

Select an option to see the answer and solution.

What is the purpose of the assert statement in Python?

Select an option to see the answer and solution.

Only problems that are recursively defined can be solved using recursion.

Select an option to see the answer and solution.