Question: Question 3 - Map - Reduce ( 2 marks ) Create a Python program that uses Map - Reduce to analyze a data set. You

Question 3- Map-Reduce (2 marks)
Create a Python program that uses Map-Reduce to analyze a data set. You must use map, filter, and reduce functions. Details:
Put a comment at the top of the question 2 Python codeblock with your name and student number.
Use a data set that consists of the numbers from 1 to 15.(0.5)
Apply a map function to the data set that will divide the value by 2 if it is even or multiply by 4 if it is odd. Print the result after the map function is applied. (0.5 marks)
Apply a filter function that will keep the value if it is between 3 and 30 inclusive. Print the result after the filter function is applied. (0.5 mark)
Apply a reduce function that will miltiply the two values if the first value is greater than the second otherwise it will add them. Print the result after reduce function is applied. (0.5 mark)
Sample Output
Resultaftermap:[4,1.0,12,2.0,20,3.0,28,4.0,36,5.0,44,6.0,52,7.0,60]
Resultafterfilter:[4,12,20,3.0,28,4.0,5.0,6.0,7.0]
Resultafterreduce:2540160.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!