@@ -3,42 +3,42 @@ tutorial: "https://www.youtube.com/watch?v=HACQ9uerCuE"
3
3
---
4
4
5
5
6
- # ` 06 ` Lambda functions in Python
6
+ # ` 06 ` Lambda Functions in Python
7
7
8
8
A ** lambda function** is a function with just one line of code and no name.
9
9
10
- It is a very special type of funcion in the world of python because you can use it as a small utility for very agile coding:
10
+ It is a very special type of function in the world of Python because you can use it as a small utility for very agile coding:
11
11
12
12
``` python
13
- # declaring a normal funcion for multiplication
13
+ # Declaring a normal function for multiplication
14
14
def multiply (p1 , p2 ):
15
15
return p1 * p2
16
16
17
- # declaring it now like a one line lambda
17
+ # Declaring it now like a one line lambda function
18
18
multiply = lambda p1 ,p2 : p1 * p2
19
19
```
20
- :point_uo: Facts:
20
+ 👉 Facts:
21
21
22
- + ** Lambda fuctions ** have to be always very small.
22
+ + ** Lambda functions ** have to always be very small.
23
23
24
- + ** Lambda function ** can only have one line.
24
+ + ** Lambda functions ** can only have one line.
25
25
26
- + ** Lambda function ** doesn 't need a ` return ` statement (it is assumed that it will return whatever is on that one line).
26
+ + ** Lambda functions ** don 't need a ` return ` statement (it is assumed that it will return whatever is on that one line).
27
27
28
- + ** Lambda functions** can be stored in variables or passed as parameters to another function
28
+ + ** Lambda functions** can be stored in variables or passed as parameters to another function.
29
29
30
30
## 📝 Instructions:
31
31
32
32
1 . Create a variable called ` is_odd ` .
33
33
34
34
2 . Assign a ** lambda function** to it that returns ` True ` or ` False ` if a given number is odd.
35
35
36
- ## 💡Hint
36
+ ## 💡 Hint
37
37
38
38
+ Here is how you would declare it like a normal function:
39
39
40
40
``` py
41
- # this function return True if a number is odd.
41
+ # This function returns True if a number is odd.
42
42
def is_odd (num ):
43
43
return num % 2 != 0
44
44
```
0 commit comments