Practice Using map(), filter(), reduce() - 6.3 | Chapter 6: Functional Programming Tools in Python | Python Advance
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Using map(), filter(), reduce()

6.3 - Using map(), filter(), reduce()

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

What does the map() function do?

💡 Hint: Think transformation or modification of a list.

Question 2 Easy

How do you filter out odd numbers from a list using filter()?

💡 Hint: Look for the condition you need to check.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What is the output of list(map(lambda x: x + 3, [1, 2, 3]))?

[1
2
3]
[4
5
6]
[2
3
4]

💡 Hint: What happens when you add 3 to each number?

Question 2

filter() returns all elements for which the provided function returns True.

True
False

💡 Hint: Think about the purpose of filtering elements.

2 more questions available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

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.

💡 Hint: Plant each step: convert, filter, then average!

Challenge 2 Hard

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.

💡 Hint: Focus on the sequence of operations and ensure each is appropriate for the next step.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.