0% found this document useful (0 votes)
9 views2 pages

Python Lambda, Map, Filter, Apply Functions

The document contains a series of programming questions focused on Python functions, specifically lambda, map, filter, and apply functions. Each section includes tasks that require the use of these functions to manipulate data, such as adding, squaring, filtering, and transforming lists and DataFrame columns. The questions are designed to test and reinforce understanding of functional programming concepts in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Python Lambda, Map, Filter, Apply Functions

The document contains a series of programming questions focused on Python functions, specifically lambda, map, filter, and apply functions. Each section includes tasks that require the use of these functions to manipulate data, such as adding, squaring, filtering, and transforming lists and DataFrame columns. The questions are designed to test and reinforce understanding of functional programming concepts in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Function Questions

Lambda Function Questions


1. Write a lambda function to add 10 to a given number.

2. Use a lambda function to square a number.

3. Create a lambda function to multiply two numbers.

4. How do you use a lambda function to find the maximum of two numbers?

5. Use a lambda function inside map() to cube all elements in the list [1, 2, 3, 4].

Map Function Questions

6. Use map() to convert a list of integers [1, 2, 3] into their squares.

7. Given two lists [1, 2, 3] and [4, 5, 6], use map() to add elements at the same
position.

8. Convert a list of strings ['1', '2', '3'] into integers using map().

9. Use map() and a lambda function to convert a list of temperatures in Celsius to


Fahrenheit.

10. Use map() to capitalize all strings in the list ['hello', 'world'].

Filter Function Questions

11. Use filter() and lambda to get only even numbers from [1, 2, 3, 4, 5, 6].

12. Filter all elements greater than 10 from the list [4, 11, 32, 9, 2] using filter().

13. Given a list of words, filter out words shorter than 5 characters.

14. Use filter() and lambda to get all numbers divisible by 3 from the list [3, 5, 9,
12, 15].

Apply Function Questions

1. Given a DataFrame column of integers, use .apply() with a lambda function to square
each value.
Python Function Questions
2. Use .apply() to convert all strings in a column to uppercase.

3. You have a DataFrame with a column Salary. Use .apply() to add a bonus of 1000
to each salary.

4. Create a function that returns "Pass" if a value is greater than 50, else "Fail". Use
.apply() to apply this function to a marks column.

5. Use .apply() with axis=1 to calculate the sum of values row-wise in a DataFrame
with numerical columns Math, Science, and English.

You might also like