Map ()
Return an iterator-Applies function to every item of iterable, yielding the results
For example:
A = map (lambda x:x**2, [I/z ])printfor in a])
Results:
[1, 4, 9]
Or:
A = map (lambda x,y:x+y, [],[1,2])print for in a])
Results:
[2, 4]
filter(function, iterable)
Construct a iterator from those elements of iterable for which function returns TRUE. If function None is, all elements of iterable the is false are removed
Example:
A = filter (lambda x:x>2, [I/z ])printfor in a])
or function isNone:
A = Filter (none,[1,2, 0,-1])print for in a])
Results:
[1, 2,-1]
Zip ()
Make a iterator that aggregates elements from each of the Iterables
Example
x = [1, 2, 3= [4, 5, 6== List (zipped)print(zipped)
Results
[(1, 4), (2, 5), (3, 6)]
Dict ()
>>> a = Dict (one=1, two=2, three=3)>>> B = {' One': 1,' Both': 2,'three': 3}>>> C = dict (Zip ([' One',' Both','three'], [1, 2, 3]))>>> d = dict ([(' Both', 2), (' One', 1), ('three'-R)])>>> e = Dict ({'three': 3,' One': 1,' Both': 2})>>> A = = b = = C = = d = =etrue
An example of a synthesis
A = map (lambda x:dict (['number'], [x])), filter (lambda x:x > 3, [ 1,2,3,4,5,6]))(print for in a])
Results
[{'number': 4}, {'number': 5}, {' number': 6}]
The Map,filter,zip function in Python