-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFMR6.py
More file actions
59 lines (37 loc) · 1.35 KB
/
FMR6.py
File metadata and controls
59 lines (37 loc) · 1.35 KB
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
CheckEven = lambda No: (No % 2 == 0) # using Lambda Function
Doubles = lambda No: No*2 # using Lambda Function
Sum = lambda A,B: A+B # using Lambda Function
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 elements you want to enter: ")
iSize = int(input())
Data_Input = []
print("Please enter the data")
for iCnt in range(0,iSize,1):
Value = int(input())
Data_Input.append(Value)
print("Data is: ",Data_Input)
Data_Filter = filterX(CheckEven, Data_Input)
print("Data After Filter is: ",Data_Filter)
Data_Map = mapX(Doubles, Data_Filter)
print("Data after map is: ",Data_Map)
Output = reduceX(Sum,Data_Map)
print("Result After Reduce is: ",Output)
if __name__ == "__main__":
main()