Python Programming - Functions - Discussion

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

numbers = [1, 2, 3, 4]
squared_numbers = list(map(multiply_by_two, numbers))
print(squared_numbers)
[1, 2, 3, 4]
[2, 4, 6, 8]
[1, 4, 9, 16]
Error
Answer: Option
Explanation:
The map() function applies the multiply_by_two 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.