-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFMR2.py
73 lines (53 loc) · 1.51 KB
/
FMR2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def CheckEven(No):
return (No % 2 == 0)
def multipllyByTwo(No):
return No*2
def sum(a,b):
return a+b
def filterX(Helper_function,Data):
result = []
for no in Data:
if(Helper_function(no)==True):
result.append(no)
return result
def mapX(Helper_Function,Data):
result = []
for no in Data:
value = Helper_Function(no)
result.append(value)
return result
def reduceX(Helper_Function,Data):
Ans = 0
for no in Data:
Ans = Helper_Function(Ans,no)
return Ans
def main():
print("Enter number of element you want to enter in list : ")
size = int(input())
Data_Input = []
for iCnt in range(0,size,1):
print("Please Enter the Data ")
value = int(input())
Data_Input.append(value)
print("Data is : ",Data_Input)
Data_filter = filterX(CheckEven,Data_Input)
print("Data after filter : ",Data_filter)
Data_Map = mapX(multipllyByTwo,Data_filter)
print("Data after map : ",Data_Map)
Data_reduce = reduceX(sum,Data_Map)
print("Result after reduce is : ",Data_reduce)
if __name__ == '__main__':
main()
# def AcceptOuput():
# print("Enter number of element you want to enter in list : ")
# size = int(input())
#
# Data_Input = []
#
# for iCnt in range(0, size, 1):
# print("Enter values")
# value = int(input())
#
# Data_Input.append(value)
#
# return Data_Input