Lecture 6.5 - Python Map Function
Lecture 6.5 - Python Map Function
5
Python Map Function
Content
● Definition
● Syntax
● Area of use
● Working with Map
sazzad@diucse
Definition
sazzad@diucse
Syntax
map(function, iterables)
Parameter Values
Parameter Description
function Required. The function to execute for each item
iterable Required. A sequence, collection or an iterator object. You can
send as many iterables as you like, just make sure the function has
one parameter for each iterable.
sazzad@diucse
Area to Use Map
● The general way that the map function works. Suppose you
have a list, tuple to other itrable collection of data, and we
would like to apply the function f to each piece of data.
data: 𝑎1 ,𝑎2 ….., 𝑎𝑛
faction: 𝑓
map(𝑓 ,data)
● With the map function, you first specify the function, then
you specify the data the iterate over. The map function will
return an iterator over the collation of f applied to each piece
of data
sazzad@diucse
Working with Map
● map(func, *iterables) --> map object
Output
sazzad@diucse
Thank You
sazzad@diucse