Python code examples for Beginners
Python code examples for Beginners - Important Points
16. | What is the output of the following code snippet? my_list = [1, 2, 3, 4] new_list = map(lambda x: x**2, my_list) print(list(new_list)) |
---|
A. [1, 2, 3, 4]
B. [1, 4, 9, 16]
C. [2, 4, 6, 8]
D. None of the above
View Answer Discuss Work SpaceAnswer: option b
Explanation:
This code snippet uses the map() function to create a new list, where each element is the square of the corresponding element in the list my_list. Therefore, the new list will be [1, 4, 9, 16].