250+ TOP MCQs on Python Mapping Functions and Answers

Tough Python Interview Questions & Answers on “Mapping Functions”.

1. What will be the output of the following Python code?

x = ['ab', 'cd']
print(len(list(map(list, x))))))

a) 2
b) 4
c) error
d) none of the mentioned
Answer: c
Clarification: SyntaxError, unbalanced parenthesis.

2. What will be the output of the following Python code?

x = ['ab', 'cd']
print(list(map(list, x)))

a) [‘a’, ‘b’, ‘c’, ‘d’]
b) [[‘ab’], [‘cd’]]
c) [[‘a’, ‘b’], [‘c’, ‘d’]]
d) none of the mentioned
Answer: c
Clarification: Each element of x is converted into a list.

3. What will be the output of the following Python code?

x = [12, 34]
print(len(list(map(len, x))))

a) 2
b) 1
c) error
d) none of the mentioned
Answer: c
Clarification: TypeError, int has no len().

4. What will be the output of the following Python code?

x = [12, 34]
print(len(list(map(int, x))))

a) 2
b) 1
c) error
d) none of the mentioned
Answer: a
Clarification: list(map()) returns a list of two items in this example.

5. What will be the output of the following Python code?

x = [12, 34]
print(len(''.join(list(map(int, x)))))

a) 4
b) 2
c) error
d) none of the mentioned
Answer: c
Clarification: Cannot perform join on a list of ints.

6. What will be the output of the following Python code?

x = [12, 34]
print(len(''.join(list(map(str, x)))))

a) 4
b) 5
c) 6
d) error
Answer: a
Clarification: Each number is mapped into a string of length 2.

7. What will be the output of the following Python code?

x = [12, 34]
print(len(' '.join(list(map(int, x)))))

a) 4
b) 5
c) 6
d) error

Answer: d
Clarification: TypeError. Execute in shell to verify.

8. What will be the output of the following Python code?

x = [12.1, 34.0]
print(len(' '.join(list(map(str, x)))))

a) 6
b) 8
c) 9
d) error
Answer: c
Clarification: The floating point numbers are converted to strings and joined with a space between them.

9. What will be the output of the following Python code?

x = [12.1, 34.0]
print(' '.join(list(map(str, x))))

a) 12 1 34 0
b) 12.1 34
c) 121 340
d) 12.1 34.0
Answer: d
Clarification: str(ab.c) is ‘ab.c’.

10. What will be the output of the following Python code?

x = [[0], [1]]
print(len(' '.join(list(map(str, x)))))

a) 2
b) 3
c) 7
d) 8
Answer: c
Clarification: map() is applied to the elements of the outer loop.

tough interview questions on Python,

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top