-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLambda-expression-exercise
41 lines (34 loc) · 2.04 KB
/
Lambda-expression-exercise
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
#Challenge 1:Create a oneliner using Lambda
#ExpressionsTo square the numbers in my_list
my_list = [5,4,3]
print(list(map(lambda item: item**2, my_list)))
#Challenge 2: List Sorting, sort by the second digit
#in the Tuple
a = [(0,2), (4,3), (9,9), (10,-1)]
print(sorted(a,key=lambda t: t[1]))
/\ /\
| \ / |
| \ / \ / |
| \ /\ / \ / \ / |
| \ ^ / \/ \/ \ ^ / |
| |
/ \
/ \ / \
/ | \ / | \
/ | \ / | \
/ | @\ /@ | \
/ | \ / | \
/ \___/ \___/ \
/ \
/ |\______________________/| \
/ \ | | | | | | | /\ \
/ / \ | | | | | | | / \ \
/ / \ | | | | | | | / \ \
/ / \ \ | | | | | / / \ \
/ \ \ \_|___|___|___|___|__/ / / \
\/\/\/ /\ /\ \/\/\/
/ \ / \
| |
| \____________________/ |
\ | | /
<_________/ \_________>