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

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Academics
Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Professional Courses
Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skillsβ€”perfect for learners of all ages.

games

Practice Questions

Test your understanding with targeted questions related to the topic.

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.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

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.

Solve 2 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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!

Question 2

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.

Challenge and get performance evaluation