Select an option to see the answer and solution.
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.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
def to_upper(k):
return k.upper()
x = ['ab', 'cd']
print(list(map(upper, x)))Select an option to see the answer and solution.
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.
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.
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.
def f(): x=4
x=1
f()
xSelect an option to see the answer and solution.
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.
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.
x = ['ab', 'cd']
print(map(len, x))Select an option to see the answer and solution.
Select an option to see the answer and solution.
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.
Select an option to see the answer and solution.
x = ['ab', 'cd']
print(list(map(len, x)))Select an option to see the answer and solution.
def f():
global a
print(a)
a = "hello"
print(a)
a = "world"
f()
print(a)Select an option to see the answer and solution.
x=12
def f1(a,b=x):
print(a,b)
x=15
f1(4)Select an option to see the answer and solution.
elements = [0, 1, 2]
def incr(x):
return x+1
print(list(map(elements, incr)))Select an option to see the answer and solution.
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.
def to_upper(k):
k.upper()
x = ['ab', 'cd']
print(list(map(to_upper, x)))Select an option to see the answer and solution.