Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.
Fun, engaging games to boost memory, math fluency, typing speed, and English skillsβperfect for learners of all ages.
Test your understanding with targeted questions related to the topic.
Question 1
Easy
Define a function is_positive(n)
that returns True if n is positive, and False otherwise. Use filter to get positive numbers from the list [-1, 0, 1, 2, -2].
π‘ Hint: Remember to define the function before using filter.
Question 2
Easy
Using filter, extract numbers greater than 10 from the list [5, 10, 15, 20, 25].
π‘ Hint: Think about how you would compare each element.
Practice 4 more questions and get performance evaluation
Engage in quick quizzes to reinforce what you've learned and check your comprehension.
Question 1
What does the filter function do in Python?
π‘ Hint: Think about what filtering means in everyday terms.
Question 2
True or False: List comprehensions can replace both map and filter functions in Python.
π‘ Hint: Consider the structure of a list comprehension.
Solve 1 more question and get performance evaluation
Push your limits with challenges.
Question 1
Create a Python function that takes a list of numbers, applies filter
to extract only positive numbers, and then uses map
to square these numbers. Return the final result.
π‘ Hint: Think about using lambdas for both filtering and mapping.
Question 2
Refactor your function to use list comprehension instead of filter and map to achieve the same result with a cleaner syntax.
π‘ Hint: Remember to incorporate both the condition and the transformation together.
Challenge and get performance evaluation