Question | Click to View Answer |
What does the following code print? add_one = lambda x: x + 1
print(add_one(7))
|
The variable |
What does the following code print? multiply_by_two = lambda x: x * 2
numbers = [1, 2, 3]
doubled = map(multiply_by_two, numbers)
doubled_list = list(doubled)
print(doubled_list)
|
The The The map object is converted to a list and then printed. |
What does the following code print? letters = ["beach", "car"]
funified = list(map(lambda word: f"{word} is fun!", letters))
print(funified)
|
The The |
What does the following code print? nums = [3, 5, 16, 27]
some_nums = list(filter(lambda num: num < 10, nums))
print(some_nums)
|
The
|
What does the following code print? words = ["bay", "cat", "boy", "fan"]
b_words = list(filter(lambda word: word.startswith("b"), words))
print(b_words)
|
The All the words that do not start with |
What does the following code print? nums = [4, 5, 6]
squares = list(map(lambda num: num ** 2, nums))
print(squares)
|
The |
What does the following code print? from functools import reduce
numbers = [1, 2, 3, 4]
sum = reduce(lambda x, y: x + y, numbers)
print(sum)
|
The |
What does the following code print? from functools import reduce
words = ["mary", "had", "a", "little", "lamb"]
biggest_word = reduce(lambda x, y: x if len(x) > len(y) else y, words)
print(biggest_word)
|
The |