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
5/10
Page
Pick an option on a question to see the right answer and solution.
x = [[0], [1]]
print((' '.join(list(map(str, x))),))Select an option to see the answer and solution.
def foo(i, x=[]):
x.append(x.append(i))
return x
for i in range(3):
y = foo(i)
print(y)Select an option to see the answer and solution.
def foo(k):
k = [1]
q = [0]
foo(q)
print(q)Select an option to see the answer and solution.
x = [12, 34]
print(len(''.join(list(map(int, x)))))Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
def power(x, y=2):
r = 1
for i in range(y):
r = r * x
return r
print power(3)
print power(3, 3)Select an option to see the answer and solution.
Select an option to see the answer and solution.
l=[-2, 4]
m=map(lambda x:x*2, l)
print(m)Select an option to see the answer and solution.
def f1(x):
global x
x+=1
print(x)
f1(15)
print("hello")Select an option to see the answer and solution.
def foo(x):
x = ['def', 'abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))Select an option to see the answer and solution.
Select an option to see the answer and solution.
def sayHello():
print('Hello World!')
sayHello()
sayHello()Select an option to see the answer and solution.
l=[1, 2, 3, 4, 5]
m=map(lambda x:2**x, l)
print(list(m))Select an option to see the answer and solution.
import functools
l=[1,2,3,4]
print(functools.reduce(lambda x,y:x*y,l))Select an option to see the answer and solution.
def foo():
total += 1
return total
total = 0
print(foo())Select an option to see the answer and solution.
Select an option to see the answer and solution.
m=reduce(lambda x: x-3 in range(4, 10))
print(list(m))Select an option to see the answer and solution.
Q100
Open questiony, z = 1, 2
def f():
global x
x = y+zSelect an option to see the answer and solution.