Python‎ > ‎

### map

Definition
Make an iterator that computes the function using arguments from
each of the iterables.

Syntax
map(function, iterable)

Parameters
function & interable

Examples
min()
The map function is used to find min() value in tuple().
 iterable1=(55,458,572,101)min_value=min(map(lambda a: a, iterable1))print(min_value)>>> 55>>>

max()
The map return with maximum value using max()
 iterable1=(55,458,572,101)max_value=max(map(lambda a: a, iterable1))print(max_value)>>> 572>>>

sum()
Return the sum of the iterable.
 interable1=(55,458,572,101)interable2=(11,3,4,5,6,6)sum_value=sum(map(lambda a,b: a+b, interable1, interable2))print(sum_value)>>> 1209>>>

tuple()
The tuple() value are summed using lambda function.
 x=(1,2,3)y=(2,1,3)z=(1,3,4)for i in map(lambda a,b,c: a+b+c, x,y,z):    print(i)>>> 4610>>>

list
The list values are:.
 x=[1,2,3]y=[2,1,3]z=[1,3,4]for i in map(lambda a,b,c: a+b+c, x,y,z):    print(i)>>> 4610>>>

set
The map method is used to return set string value to lower case.
 name={"python","Lake", "research", "Centre"}for a in map(lambda x: x.lower(),name):    print(a)>>> centreresearchlakepython>>>

The map method returns with sum of three sets.
 x={1,2,3}y={2,1,3}z={1,3,4}for i in map(lambda a,b,c: a+b+c, x,y,z):    print(i)      >>> 3710>>>

map.__eq__
The method return with the equality test whether the max() of the map() is equal to pow(23, 3).
 x=(11,23,444,333)y=max(map(lambda a: a, x)).__eq__(pow(22,3))print(y)>>> False>>>

The determined that the maximum value of set is not equal to round(.99).
 import mathtuple=(math.acos(1),math.asin(.22),math.cos(-1.1), math.atan(.99))y=max(map(lambda a: a, tuple)).__ne__(round(1.1))print(y)>>> False>>>

sum(map())
The function returns with the sum of three tuple.
 import mathx=(math.acos(1),math.asin(1),math.atan(1))y=(math.sin(-1),math.cos(-1),math.tan(-1))z=(math.cosh(.1),math.sinh(.1),math.tanh(.1))print("The sum is", sum(map(lambda a,b,c: a+b+c, x,y,z)))>>>The sum is 1.7024569992982896>>>

for statement
Method run the loop for sets.
 import mathset1={math.trunc(1.1),math.sqrt(49),math.pow(4,2),math.e,math.exp(44)}set2={math.floor(3.12),math.fmod(3,2),math.fabs(22), math.ceil(1)}for i in map(lambda a,b: a+b, set1, set2):print(i)>>> 17.0424.718281828459045>>>

if statement sum(map(lamda))__lt__(value()
If statement returns that the sum of the x/y is not less than 2.
 import mathx={math.factorial(81),math.sqrt(49),math.pow(4,2),math.e,math.exp(44)}y={math.floor(3.12),math.fmod(3,2),math.fabs(22), math.ceil(1)}if sum(map(lambda a,b: a/b, x,y)).__lt__(2):                                                        print("The sum of x and y is less than 2")else:       print("The sum of x and y is greater than 2.")>>> The sum is greater than 2.>>>

if statement sum(map(lambda).__le__()
The lambda returns with equation computation.
 import mathx=[math.log(2,10),math.log10(22), math.log2(2)]y=[math.trunc(2.1)]if sum(map(lambda a,b: a+b/2, x,y)).__le__(y):    print("The return is large or equal to 2.0")else:   print("The value does not meet the criteria")>>> The return is large or equal to 2.0>>>

if min(map(lambda(decimal,decimal)).__gt__()
The method returns with the minimum value in the sets equation set1/set2*set2 is greater than 2.
 set1={Decimal(-1355).adjusted(),Decimal(-233.321).copy_negate(), Decimal(-23.99).exp()}set2={ Decimal(2.0).fma(3,7),Decimal(1.1).log10()}if min(map(lambda a,b: a/b*b, set1, set2)).__gt__(2):        print("Return is greater than 2.")else:        print("Not within parameters")>>> Return is greater than 2.>>>

map(lambda(function, iterable).__sizeof__()
The function returns with the str(object) in bytes.
 a="python centre research"i=(map(lambda x: x, a)).__sizeof__()print(i)>>> 32>>>

if (map(lambda function, string).__sizeof__.__gt__()
The method returns that a string size is greater than 22.
 str="python centre research"if (map(lambda x: x, str)).__sizeof__().__gt__(22):    print(str.__str__())else:    print("The string bytes size is greater than 22.")>>> python centre research>>>

The method used the math values to generate random using operator.truediv()
 import operatorimport randomimport matha=math.acos(.65)b=math.asin(.45)c=math.atan(1)d=random.betavariate(a,b)f=random.gauss(b,c)g=random.gammavariate(c,a)h=operator.truediv(d,f)i=operator.truediv(f,g)j=operator.truediv(g,d)list=[h,i,j]l=max(map(lambda x:x, list))print(l)>>> 426.5194858354276>>>

Subpages (22):