File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## FIND THE SQUARE OF A NUMBER USING LEMBDA FUNCTION
2
+
1
3
square = lambda num : num ** 2
2
- print (square (8 ))
4
+ print (square (8 ))
5
+
6
+ ## REVERSE A STRING USING LAMBDA FUNCTION
7
+
8
+ str = 'hello guys'
9
+ # lambda returns a function object
10
+ rev_upper = lambda string : string .upper ()[::- 1 ]
11
+ print (rev_upper (str ))
12
+
13
+ ## MAP OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION
14
+
15
+ mynums = [1 ,2 ,3 ,4 ,5 ]
16
+ print (list (map (lambda num : num % 2 == 0 ,mynums )))
17
+
18
+ ## FILTER OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION
19
+ mynums = [1 ,2 ,3 ,4 ,5 ]
20
+ print (list (filter (lambda num : num % 2 == 0 ,mynums )))
21
+
22
+ # FIND MAXIMUM NUMBER BETWEEN TWO NUMBERS USING LEMBDA FUNCTION
23
+ Max = lambda a , b : a if (a > b ) else b
24
+ print (Max (8 , 4 ))
25
+
You can’t perform that action at this time.
0 commit comments