Test Series - python

Test Number 74/108

Q: 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)))
A. [1, 2, 3]
B. [0, 1, 2]
C. error
D. none of the mentioned
Solution: The list should be the second parameter to the mapping function.
Q: What will be the output of the following Python code?

elements = [0, 1, 2]
def incr(x):
    return x+1
print(list(map(incr, elements)))
A. [1, 2, 3]
B. [0, 1, 2]
C. error
D. none of the mentioned
Solution: Each element of the list is incremented.

You Have Score    /2