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

3/10

Page

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

Which of these is false about a package?

Select an option to see the answer and solution.

Lambda contains block of statements.

Select an option to see the answer and solution.

What happens if the base condition isn't defined in recursive programs?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Observe the following Python code?
def a(n):
    if n == 0:
        return 0
    else:
        return n*a(n - 1)
def b(n, tot):
    if n == 0:
        return tot
    else:
        return b(n-2, tot-2)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def a(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return a(n-1)+a(n-2)
for i in range(0,4):
    print(a(i),end=" ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
def printMax(a, b):
    if a > b:
        print(a, 'is maximum')
    elif a == b:
        print(a, 'is equal to', b)
    else:
        print(b, 'is maximum')
printMax(3, 4)

Select an option to see the answer and solution.

What will be the output of the following Python code?
def f(): x=4
x=1
f()
x

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=[1, -2, -3, 4, 5]
def f1(x):
    return x<-1
m1=map(f1, l)
print(list(m1))

Select an option to see the answer and solution.

What will be the output of the following Python code?
a=10
b=20
def change():
    global b
    a=45
    b=56
change()
print(a)
print(b)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

How are required arguments specified in the function heading?

Select an option to see the answer and solution.

What will be the output of the following Python code?
def check(n):
    if n < 2:
        return n % 2 == 0
    return check(n - 2)
print(check(11))

Select an option to see the answer and solution.

What is tail recursion?

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(len, x)))

Select an option to see the answer and solution.

What will be the output of the following Python code?
def f():
    global a
    print(a)
    a = "hello"
    print(a) 
a = "world" 
f()
print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x=12
def f1(a,b=x):
    print(a,b)
x=15
f1(4)

Select an option to see the answer and solution.

What will be the output of the following Python code?
elements = [0, 1, 2]
def incr(x):
    return x+1
print(list(map(elements, incr)))

Select an option to see the answer and solution.

What will be the output of the following Python code?
def test(i,j):
    if(i==0):
        return j
    else:
        return test(i-1,i+j)
print(test(4,7))

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.