Python OOPs


Python SQLite


Examples


Others


Python Map Function


The map() function executes a specified function for each item in an iterable. The item is sent to the function as a parameter.

Syntax
map(function, iterator1,iterator2 ...iteratorN)

Write a Python program to print the square values of a given list using map.

Example
a=[1,2,3,4,5]

def sqr(a):
    return a**2
b=list(map(sqr,a))
print(b)
Output
[1, 4, 9, 16, 25]