What does the map method do in Python

0 votes
What is the purpose of using map() function?
Jun 17, 2019 in Python by Wajiha
• 1,960 points
784 views

1 answer to this question.

0 votes

The map() function in Python is a function that applies a given function to all the iterables and returns a new list.

SYNTAX:

map(function, iterable)

Let’s take an example to demonstrate the use of the lambda functions within the map() function:

EXAMPLE:

1

2

3

my_list = [2,3,4,5,6,7,8]

new_list = list(map(lambda a: (a/3 != 2), li))

print(new_list)

OUTPUT:

[True, True, True, True, False, True, True]

The above output shows that, whenever the value of the iterables is not equal to 2 when divided by 3, the result returned should be True. Hence, for all elements in my_list, it returns true except for the value 6 when the condition changes to False.

answered Jun 17, 2019 by anonymous

Related Questions In Python

+1 vote
1 answer

What does the Raise keyword do in Python?

Hi! I think I can answer this - ...READ MORE

answered Jan 25, 2019 in Python by Nymeria
• 3,560 points
1,158 views
0 votes
1 answer

What does the penup() do in Python(turtle module)

penup() basically makes sure that the moving ...READ MORE

answered Jun 21, 2019 in Python by Iris
6,566 views
0 votes
1 answer

What does the operator "/=" do in python?

x = 20 res = x /= 5 print(res) The ...READ MORE

answered Aug 2, 2019 in Python by Mohammad
• 3,230 points
856 views
0 votes
1 answer

What does the dir() function do in python?

The dir() function returns all properties and methods of ...READ MORE

answered Aug 6, 2019 in Python by Mohammad
• 3,230 points
945 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,465 views
0 votes
1 answer
0 votes
1 answer

What does the return statement do in Python?

The print() function is use to write ...READ MORE

answered Oct 1, 2018 in Python by SDeb
• 13,300 points
1,388 views
0 votes
1 answer

What does the random.triangular(low, high, mode) function do in python?

It returns a random floating point number ...READ MORE

answered May 27, 2019 in Python by Vinod
1,097 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP