menu

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

Discuss Work Space

Answer: 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].



Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now