- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction_Party.py
More file actions
Latest commit
39 lines (24 loc) · 926 Bytes
/
Copy pathFunction_Party.py
File metadata and controls
39 lines (24 loc) · 926 Bytes
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
deffunnyfunction(first_word,second_word,third_word):
print("The word created is: "+first_word+second_word+third_word)
returnfirst_word+second_word+third_word
defwordprinter(sample_word):
forxinrange(0, len(sample_word)):
print("The letter in ", x, " is ", sample_word[x])
wordprinter(funnyfunction('chicken', 'fish', 'fart'))
# How to use Lambdas?
numbers_from_x=sorted([45, 34, 2, 3, 4, 20, -10], key=lambdax: abs(10-x))
print(numbers_from_x)
numbers_from_x=sorted([0, -5, 20, -25, 36, -80, 100, -180], key=lambdax: x%7)
print(numbers_from_x)
defdo_stuff(n):
returnlambdax: (x+n) *n
f=do_stuff(3)
print(f(4))
my_list= [1, 2, 3, 4, 5, 6]
squared_list=map(lambdax: x**2, my_list)
print(list(squared_list))
square_root=lambdax: x**0.5
print(square_root(4))
importmath
defsquare_root(x): returnmath.sqrt(x)
print(square_root(4))