Test Series - python

Test Number 76/108

Q: What will be the output of the following Python code?

x = [[0], [1]]
print((.join(list(map(str, x)))))
A. (‘[0] [1]’,)
B. (’01’,)
C. [0] [1]
D. 01
Solution: (element) is the same as element. It is not a tuple with one item.
Q: What will be the output of the following Python code?

x = [[0], [1]]
print((.join(list(map(str, x))),))
A. (‘[0] [1]’,)
B. (’01’)
C. [0] [1]
D. 01
Solution: (element,) is not the same as element. It is a tuple with one item.
Q: What will be the output of the following Python code?

x = [34, 56]
print(('.join(list(map(str, x))),))
A. 3456
B. (3456)
C. (‘3456’)
D. (‘3456’,)
Solution: We have created a tuple with one string in it.
Q: What will be the output of the following Python code?

x = [34, 56]
print(('.join(list(map(str, x)))),)
A. 3456
B. (3456)
C. (‘3456’)
D. (‘3456’,)
Solution: We have just created a string.
Q: What will be the output of the following Python code?

x = [34, 56]
print(len(map(str, x)))
A. [34, 56]
B. [’34’, ’56’]
C. 34 56
D. error
Solution: TypeError, map has no len.
Q: What will be the output of the following Python code?

x = abcd
print(list(map(list, x)))
A. [‘a’, ‘b’, ‘c’, ‘d’]
B. [‘abcd’]
C. [[‘a’], [‘b’], [‘c’], [‘d’]]
D. none of the mentioned
Solution: NameError, we have not defined abcd.
Q: What will be the output of the following Python code?

x = 1234
print(list(map(list, x)))
A. [1, 2, 3, 4]
B. [1234]
C. [[1], [2], [3], [4]]
D. none of the mentioned
Solution: TypeError, int is not iterable.
Q: What will be the output of the following Python code?

x = 1234
print(list(map(list, [x])))
A. [1, 2, 3, 4]
B. [1234]
C. [[1], [2], [3], [4]]
D. none of the mentioned
Solution: TypeError, int is not iterable.

You Have Score    /8