Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What does the map() function do?
Think transformation or modification of a list.
How do you filter out odd numbers from a list using filter()?
Look for the condition you need to check.
What is the output of list(map(lambda x: x + 3, [1, 2, 3]))?
What happens when you add 3 to each number?
filter() returns all elements for which the provided function returns True.
Think about the purpose of filtering elements.
Using map(), filter(), and reduce(), write a Python program that processes a list of temperatures in Celsius. Convert them to Fahrenheit, filter out the temperatures below freezing, and find the average of the remaining temperatures.
Plant each step: convert, filter, then average!
Design a function that takes a list of strings, uses map() to find their lengths, filter() to remove strings shorter than 5 characters, and finally uses reduce() to concatenate the remaining strings.
Focus on the sequence of operations and ensure each is appropriate for the next step.
6 more questions in this section. Enroll free to practise them all.
Enroll free