Practice - Examples
Practice Questions
Test your understanding with targeted questions
What does the following list comprehension generate? [x ** 2 for x in range(5)]
💡 Hint: Think of squaring numbers from 0 to 4.
How can you use filter to get only odd numbers from a list?
💡 Hint: Remember the modulo operator to check for odd numbers.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does the following code snippet return: list(map(lambda x: x**3, [1, 2, 3]))?
💡 Hint: Think of the operation of raising to the power of 3.
Is it true that filter function can only return a list?
💡 Hint: Recall the output of functional programming functions.
2 more questions available
Challenge Problems
Push your limits with advanced challenges
Create a list comprehension that generates all non-repeating Pythagorean triples from numbers 1 to 50.
💡 Hint: Remember to prevent duplicates by adjusting the ranges.
Write a single-line comprehension that creates a list of tuples representing (number, square) for the first ten natural numbers.
💡 Hint: Think about how you can use grouping within parentheses.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.