Python Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 22)
22.
What will be the output of the following code snippet?
def square(x):
    return x ** 2

numbers = [1, 2, 3, 4]
squared_numbers = list(map(square, numbers))
print(squared_numbers)
[1, 4, 9, 16]
[1, 2, 3, 4]
[2, 4, 6, 8]
Error
Answer: Option
Explanation:
The map() function applies the square function to each element in the numbers list.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.