Vidyalelo
Python · Q47

Python Introduction and basic

Programming · Python · question 47

Q47

What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),))

A.
01
B.
[0] [1]
C.
('01')
D.
('[0] [1]',)
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
In the given code, the variable x is assigned a list containing two sublists: [[0], [1]].
The map() function is used to apply the str() function to each element of x, converting them to strings.
Then, list() is used to convert the resulting map object to a list.
The join() function concatenates these strings with a space separator.
Finally, the result is enclosed in a tuple using (...) and printed.
Therefore, the output will be: ('[0] [1]',).