Lecture
Coding Quiz - Extract Elements from List
In this Python coding quiz, you'll write a function that extracts elements from a list based on a specific condition using the filter and map functions, then applies a transformation to each extracted element.
The function below, named solution, should take a list of integers as input, extract only the odd numbers, and return a new list with each extracted odd number multiplied by 2.
Function Parameter Format
def solution(numbers): # Write your code here return
Constraints
-
The input list consists of integers.
-
The output list should contain the result of multiplying each odd element from the input list by 2.
Example Input and Output
-
Input:
[1, 2, 3, 4, 5] -
Output:
[2, 6, 10]
Lessons in this chapter · Recursive and Lambda Functions
- 1. Functions That Call Themselves - Recursive Functions
- 2. Comparing Loop and Recursive Functions
- 3. Enhancing Recursive Function Efficiency with Memoization
- 4. Handling UnboundLocalError in Recursion
- 5. Multiple-choice quiz
- 6. Using Functions and Tuples Together
- 7. Functions within Functions - Callback Functions
- 8. Processing Sequences with filter() and map() Functions
- 9. Multiple-choice quiz
- 10. Creating Concise Anonymous Functions with Lambda
- 11. Calculating Fibonacci Sequence Using Lambda Functions
- 12. Coding Quiz - Extract Elements from List
- 13. Multiple-choice quiz
- 14. Fill-in-the-blank quiz
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help