Q: What will be the output of the following Python code? x = [12, 34] print(len(list(map(len, x))))
Solution: TypeError, int has no len().
Q: What will be the output of the following Python code? x = [12, 34] print(len(list(map(int, x))))
Solution: list(map()) returns a list of two items in this example.
Q: What will be the output of the following Python code? x = [12, 34] print(len('.join(list(map(int, x)))))
Solution: Cannot perform join on a list of ints.
Q: What will be the output of the following Python code? x = [12, 34] print(len('.join(list(map(str, x)))))
Solution: Each number is mapped into a string of length 2.
Q: What will be the output of the following Python code? x = [12, 34] print(len(.join(list(map(int, x)))))
Solution: TypeError. Execute in shell to verify.
Q: What will be the output of the following Python code? x = [12.1, 34.0] print(len(.join(list(map(str, x)))))
Solution: The floating point numbers are converted to strings and joined with a space between them.
Q: What will be the output of the following Python code? x = [12.1, 34.0] print(.join(list(map(str, x))))
Solution: str(ab.c) is ‘ab.c’.
Q: What will be the output of the following Python code? x = [[0], [1]] print(len(.join(list(map(str, x)))))
Solution: map() is applied to the elements of the outer loop.
You Have Score    | /8 |