0% found this document useful (0 votes)
30 views3 pages

Practical - 1

2

Uploaded by

Ritesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Practical - 1

2

Uploaded by

Ritesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Faculty of Engineering & Technology

Subject Name : BDA Lab


Subject Code : 203105348
B.Tech:CSE Year:4th Semester:7th

PRACTICAL-1
AIM:- To understand the overall programming
architecture using Map Reduce API.

The MapReduce task is mainly divided into two phases Map Phase and Reduce
Phase.

1. map(), filter(), and reduce() in Python.


2.These functions are most commonly used with Lambda function.

1. map():
"A map function executes certain instructions or functionality provided to it on
every item of an iterable."The iterable could be a list, tuple, set, etc.

SYNTAX:
map(function, iterable)

Example:
items = [1, 2, 3, 4, 5]
a=list(map((lambda x: x **3), items))
print(a)

OUTPUT:

The map()function passes each element in the list to a lambda function and
returns the mapped object.

2.filter():-
"A filter function in Python tests a specific user-defined condition for a function
and returns an iterable for the elements and values that satisfy the condition or,
in other words, return true."

Page 1|3
Enrollment No:-2203051057087
Faculty of Engineering & Technology
Subject Name : BDA Lab
Subject Code : 203105348
B.Tech:CSE Year:4th Semester:7th

SYNTAX:
filter(function, iterable)

Example:
a = [1,2,3,4,5,6]
b = [2,5,0,7,3]
c= list(filter(lambda x: x in a, b))
print(c)

OUTPUT:

3.reduce():
"Reduce functions apply a function to every item of an iterable and gives back a
single value as a resultant".

we have to import the reduce function from functools module using the
statement

SYNTAX:
reduce(function, iterable)

Example:
from functools import reduce
a=reduce( (lambda x, y: x * y), [1, 2, 3, 4] )
print(a)

OUTPUT:

Page 2|3
Enrollment No:-2203051057087
Faculty of Engineering & Technology
Subject Name : BDA Lab
Subject Code : 203105348
B.Tech:CSE Year:4th Semester:7th

Page 3|3
Enrollment No:-2203051057087

You might also like