All quizzesEasy
map, filter & reduce — Series 3
Preview — 3 of 10 questions
What is the output of the following code?
javascript
a = [1, 2, 3]
b = [10, 20, 30]
sums = (x + y for x, y in zip(a, b))
print(list(sums))
print(sum(x + y for x, y in zip(a, b)))A[11, 22, 33], 66
B[(1, 10), (2, 20), (3, 30)], 66
C[11, 22, 33], [11, 22, 33]
D[1, 2, 3, 10, 20, 30], 66
What is the output of the following code?
javascript
def check(n):
print(f"checking {n}")
return n > 0
print(any(check(n) for n in [1, -2, 3]))
print(all(check(n) for n in [1, -2, 3]))Achecking -2, False, checking 1, True
Bchecking 1, True, checking 1, checking -2, False
Cchecking 1, checking -2, checking 3, True, checking 1, checking -2, checking 3, False
Dchecking 1, True, checking 1, checking -2, checking 3, False
What is the output of the following code?
javascript
from functools import reduce
nums = [1, 2, 3, 4, 5]
product = reduce(lambda acc, x: acc * x, nums)
print(product)
product_with_start = reduce(lambda acc, x: acc * x, nums, 10)
print(product_with_start)A120, 120
B24, 240
C120, 1200
D15, 25
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.