Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,430 --> 00:00:07,530
All right, so we're back and in one of our previous examples, I think it was in our previous video,
2
00:00:07,530 --> 00:00:13,560
hopefully if everything is arranged correctly, we talked about how we can implement these even function.
3
00:00:14,310 --> 00:00:20,910
Any of these video I want us to do is simply to implement another function in this function will be
4
00:00:20,910 --> 00:00:23,360
called Is Khaled OK?
5
00:00:23,370 --> 00:00:25,140
This will be the name of the function.
6
00:00:25,470 --> 00:00:34,050
And this function will what it will do is just this function will receive an integer, OK, and it will
7
00:00:34,050 --> 00:00:41,340
return one if this given if this given number is order.
8
00:00:41,890 --> 00:00:42,570
All right.
9
00:00:43,380 --> 00:00:53,010
And otherwise if it's not odd, meaning if it's if this number is even otherwise, this function should
10
00:00:53,010 --> 00:00:56,940
return, should return zero.
11
00:00:57,270 --> 00:01:03,150
OK, so if it's even if it should return zero.
12
00:01:03,390 --> 00:01:03,980
All right.
13
00:01:05,010 --> 00:01:08,760
And I want you to take also a few minutes to think about it.
14
00:01:08,760 --> 00:01:11,150
I think it's very trivial to solve it.
15
00:01:12,120 --> 00:01:14,940
We are going to solve it in two different ways.
16
00:01:14,940 --> 00:01:22,710
So start with the most basic, with the most intuitive solution and simply write write it down pretty
17
00:01:22,710 --> 00:01:31,080
much like you've done it for even just change a couple of lines to make it suitable for is odd.
18
00:01:31,290 --> 00:01:35,030
OK, so take a few moments and we will continue right away.
19
00:01:35,760 --> 00:01:36,340
Awesome.
20
00:01:36,630 --> 00:01:39,270
So let's start in.
21
00:01:39,270 --> 00:01:45,150
The signature of the function is going to be pretty much the same except just the function name.
22
00:01:45,160 --> 00:01:49,570
So it is odd and the function is going also to receive a number.
23
00:01:49,680 --> 00:01:59,070
So it's not like we do not really care about the fact that these function uses these even are this function
24
00:01:59,070 --> 00:02:03,870
is even is using enum and also that this function is odd is using enum.
25
00:02:04,850 --> 00:02:10,310
Basically, we know that these functions can be treated like different rooms and different rooms have
26
00:02:10,310 --> 00:02:14,580
their own naming for the values they are using.
27
00:02:15,710 --> 00:02:20,050
So it is odd and the function goes like this.
28
00:02:20,060 --> 00:02:30,020
So if no modulo two does not equal to zero, which means it is an odd number, then in this case simply
29
00:02:30,020 --> 00:02:30,950
a return one.
30
00:02:31,160 --> 00:02:33,620
Otherwise return to zero.
31
00:02:33,950 --> 00:02:38,930
OK, so pretty much almost the same solution as it was previously.
32
00:02:38,930 --> 00:02:44,540
Just that here we used the inequality sign and here we used the equality sign.
33
00:02:45,320 --> 00:02:54,350
Here it was regarding even numbers and here it's regarding odd numbers.
34
00:02:54,590 --> 00:03:02,420
OK, so if the result of the condition here is true, then these will be executed and it will mean that
35
00:03:02,420 --> 00:03:04,910
the number itself is even in here.
36
00:03:04,910 --> 00:03:06,150
It will mean it's odd.
37
00:03:06,510 --> 00:03:10,670
OK, so I hope this standard solution is clear to you.
38
00:03:10,670 --> 00:03:19,280
And I'm going to show you also additional option to how we can, instead of writing down the body of
39
00:03:19,280 --> 00:03:26,780
this function like this, how we can use the fact that we how we can call this function is even and
40
00:03:26,780 --> 00:03:30,030
implement these odd function by using these even.
41
00:03:30,230 --> 00:03:31,660
OK, so that's right.
42
00:03:32,180 --> 00:03:37,850
Additional function called is odd number two and it will simply look like this.
43
00:03:37,850 --> 00:03:39,070
So isn't odd.
44
00:03:39,410 --> 00:03:40,730
It is odd.
45
00:03:40,850 --> 00:03:44,450
Let's call it two and it would receive also none.
46
00:03:45,470 --> 00:03:53,900
And now what this function is going to do is simply to call the even function and to basically to decide
47
00:03:54,080 --> 00:03:59,630
what it should return based on the result given from is even function.
48
00:04:00,500 --> 00:04:10,380
So for that, let us go like this, so if is even returns us one for a number, right?
49
00:04:10,400 --> 00:04:15,580
So if it returns this one, it's right down in the parentheses here.
50
00:04:16,480 --> 00:04:26,390
OK, so if it returns this one, then what it means is that the number is even an hour is odd to should
51
00:04:26,390 --> 00:04:27,950
return to zero.
52
00:04:27,980 --> 00:04:28,310
Right.
53
00:04:28,310 --> 00:04:32,690
Because it's odd returns zero if the number is even.
54
00:04:33,140 --> 00:04:37,680
So based on the call of this function is even with numbers.
55
00:04:38,000 --> 00:04:45,590
We know that, we know that these function returns one only if it's an even number, then in this case
56
00:04:45,590 --> 00:04:53,990
this is all the function should return zero else we know or else we know that the function should return
57
00:04:54,350 --> 00:04:54,890
one.
58
00:04:55,820 --> 00:04:57,690
So is that clear to you guys?
59
00:04:57,860 --> 00:04:58,750
What do you think?
60
00:04:59,870 --> 00:05:01,860
Do you agree with the second solution?
61
00:05:02,600 --> 00:05:10,700
I agree that the first one looks easier, but here you practice the way you call another function.
62
00:05:10,730 --> 00:05:15,240
OK, so first of all, you will call these are two, you will give it to another.
63
00:05:15,350 --> 00:05:23,360
And here behind the scenes, this function will use a totally different function to like to calculate
64
00:05:23,360 --> 00:05:30,980
something or to check out something in based on the result of this function, you will return some value
65
00:05:31,130 --> 00:05:33,700
of this current function is odd to.
66
00:05:34,730 --> 00:05:38,630
So I hope this is clear to you because that's also very important.
67
00:05:38,720 --> 00:05:44,510
Like to grasp the idea of calling another function from a given function.
68
00:05:45,140 --> 00:05:51,710
And that's something you're going to do a lot in your programming career because you're going to write
69
00:05:51,710 --> 00:05:59,330
also complicated functions that will require the usage of other other functions in order to construct
70
00:05:59,330 --> 00:05:59,600
them.
71
00:06:00,830 --> 00:06:04,090
And with that being said, guys, I hope you like this video.
72
00:06:04,190 --> 00:06:05,770
Let me know what you think of it.
73
00:06:05,780 --> 00:06:07,970
If you have any questions, leave some review.
74
00:06:08,600 --> 00:06:15,500
And of course, as always, and we'll see you in you in the next video is I think there are a lot of
75
00:06:15,500 --> 00:06:15,980
prak.
76
00:06:15,980 --> 00:06:17,500
There is a lot of practice to us.
77
00:06:18,130 --> 00:06:18,830
I'll see you then.
7536
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.