map, filter & reduce

Preview — 3 of 10 questions

What is the output of the following code?

javascript
nums = [1, 2, 3]
result = map(lambda x: x * 2, nums)
print(result)
print(list(result))
A<map object at 0x...> then [2, 4, 6]
B[2, 4, 6] then [2, 4, 6]
C<map object at 0x...> then <map object at 0x...>
DTypeError: 'map' object is not callable

What is the output of the following code?

javascript
nums = [1, 2, 3, 4, 5, 6]
evens = filter(lambda x: x % 2 == 0, nums)
print(list(evens))
A[1, 3, 5]
BTypeError
C[True, False, True, False, True, False]
D[2, 4, 6]

Which statement about lambda functions in Python is correct?

AA lambda cannot accept default argument values.
BA lambda body must be a single expression — it cannot contain statements like if/else blocks, for loops, or assignments.
CA lambda body can contain multiple statements separated by semicolons, just like a regular function.
DA lambda cannot be assigned to a variable name.

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.