1
00:00:00,009 --> 00:00:03,299
We're going to take a break from replit and talk

2
00:00:03,309 --> 00:00:06,860
a little bit about algorithms because believe it or not,

3
00:00:07,159 --> 00:00:09,510
we're actually going to start working with

4
00:00:09,520 --> 00:00:13,739
slightly more advanced concepts in Python programming.

5
00:00:13,750 --> 00:00:16,379
And it's very, very important for you

6
00:00:16,850 --> 00:00:21,510
to understand what algorithms are because they are vital,

7
00:00:21,940 --> 00:00:25,950
not just for Python but any kind of programming language for that matter.

8
00:00:26,870 --> 00:00:31,459
Now, if I was to give you kind of like the standard definition of what an algorithm is,

9
00:00:31,469 --> 00:00:34,049
it's basically just like a set of instructions

10
00:00:34,439 --> 00:00:38,869
that need to be followed in order to arrive at a particular result.

11
00:00:39,029 --> 00:00:39,490
OK.

12
00:00:40,380 --> 00:00:44,919
In this case, right now, you can see this text, I have written some stuff there.

13
00:00:45,659 --> 00:00:48,880
The very first statement says if

14
00:00:49,159 --> 00:00:52,069
the computer is running fast,

15
00:00:53,290 --> 00:00:53,979
finish.

16
00:00:54,880 --> 00:00:56,139
Now, what do I mean here?

17
00:00:56,150 --> 00:01:00,340
I'm simply saying that look, if our computer is performing very, very well,

18
00:01:00,349 --> 00:01:01,819
it's running very, very quickly.

19
00:01:02,360 --> 00:01:07,540
There is no need to check for anything, it's fine, right? That's why I said finish.

20
00:01:08,339 --> 00:01:11,519
But then notice on the third line, I said

21
00:01:12,959 --> 00:01:15,739
you could also say something like but

22
00:01:15,959 --> 00:01:17,860
right? But in programming language

23
00:01:18,269 --> 00:01:20,680
we don't use but we use,

24
00:01:20,860 --> 00:01:21,489
all right.

25
00:01:21,790 --> 00:01:22,120
So

26
00:01:22,529 --> 00:01:28,980
basically is signifying that if the previous statement is not correct.

27
00:01:29,650 --> 00:01:33,269
So if the computer isn't running fast,

28
00:01:34,169 --> 00:01:36,879
ok, then what do we now need to do?

29
00:01:38,080 --> 00:01:40,529
We need to, first of all check if there is a virus

30
00:01:41,430 --> 00:01:46,389
and then after that, we might need to uninstall unnecessary programs

31
00:01:47,069 --> 00:01:50,519
and then we might eventually need to increase the ramp.

32
00:01:50,529 --> 00:01:52,900
So if we follow these three steps, a

33
00:01:53,300 --> 00:01:54,449
computer

34
00:01:54,779 --> 00:01:58,290
will be guaranteed to run faster.

35
00:01:59,150 --> 00:02:03,720
This is a go with him, right? And two keywords here are the if

36
00:02:04,059 --> 00:02:05,529
and else

37
00:02:05,650 --> 00:02:09,179
we're going to be working with this quite a lot in

38
00:02:09,470 --> 00:02:10,630
this course.

39
00:02:10,880 --> 00:02:14,320
And if you are ever going to work with a different kind of programming language,

40
00:02:14,589 --> 00:02:17,770
you will always come across if else, statements,

41
00:02:17,779 --> 00:02:21,770
these are fundamental building blocks of any program.

42
00:02:22,750 --> 00:02:25,130
I hope you understand what we did here

43
00:02:25,410 --> 00:02:26,410
pretty straightforward.

44
00:02:27,179 --> 00:02:27,830
I'm gonna

45
00:02:28,080 --> 00:02:32,360
make this just a little bit more advanced. Ok. Just a little bit. All right.

46
00:02:33,070 --> 00:02:34,139
Let me open up the

47
00:02:34,339 --> 00:02:35,130
second tab.

48
00:02:36,089 --> 00:02:36,589
So

49
00:02:37,429 --> 00:02:41,639
imagine you're getting dressed based on the weather.

50
00:02:42,070 --> 00:02:42,889
Ok. So

51
00:02:43,199 --> 00:02:46,610
the very first statement we've established a scenario, right?

52
00:02:47,279 --> 00:02:49,619
So our program is checking to see

53
00:02:49,940 --> 00:02:54,139
what we should wear based on the weather.

54
00:02:54,559 --> 00:02:55,179
So

55
00:02:55,300 --> 00:02:56,979
we have the very first result

56
00:02:58,029 --> 00:03:00,410
if the weather is sunny.

57
00:03:00,559 --> 00:03:03,839
Ok. Well, we can wear our sunglasses.

58
00:03:05,600 --> 00:03:06,259
However,

59
00:03:07,389 --> 00:03:11,669
notice the third line it goes else if

60
00:03:12,889 --> 00:03:15,850
it's no longer just else,

61
00:03:16,009 --> 00:03:16,630
why?

62
00:03:17,729 --> 00:03:22,440
Well, because the weather can come in various forms,

63
00:03:22,610 --> 00:03:27,149
it could be sunny, it could be rainy, it could be snowing, it could be cloudy.

64
00:03:27,449 --> 00:03:32,160
There's a lot more options. Right. In the very first document here,

65
00:03:32,300 --> 00:03:36,149
there are only two conditions. The first condition is, is the computer running fast

66
00:03:36,279 --> 00:03:38,220
or is it not running fast?

67
00:03:38,330 --> 00:03:38,910
That's it.

68
00:03:39,199 --> 00:03:40,100
Nothing

69
00:03:40,320 --> 00:03:45,839
like. Is the computer running at 25% capacity? Is it running at 50% capacity?

70
00:03:45,899 --> 00:03:48,149
We don't have any other conditions. It's just to

71
00:03:48,289 --> 00:03:51,919
either the company is running fast or it isn't. It's either A or B

72
00:03:52,020 --> 00:03:55,339
that's why if else would work perfectly here.

73
00:03:55,350 --> 00:03:59,899
However, in this example, we have more than two options

74
00:04:00,679 --> 00:04:02,539
because again, we're dealing with the weather.

75
00:04:03,339 --> 00:04:03,800
So

76
00:04:04,770 --> 00:04:05,710
if it's sunny,

77
00:04:06,410 --> 00:04:08,100
we can wear our sunglasses.

78
00:04:08,860 --> 00:04:12,169
Else if it's raining,

79
00:04:12,600 --> 00:04:14,399
ok, we can take an umbrella

80
00:04:15,470 --> 00:04:18,829
and then else if it's snowing,

81
00:04:19,309 --> 00:04:22,089
we can put on a heavy coat,

82
00:04:22,459 --> 00:04:23,010
right?

83
00:04:23,839 --> 00:04:27,700
But now look at the very last line, it simply says else,

84
00:04:28,209 --> 00:04:30,220
not else if else

85
00:04:30,890 --> 00:04:33,750
because basically we are concluding

86
00:04:33,970 --> 00:04:34,950
the program here.

87
00:04:34,959 --> 00:04:38,829
We're saying, ok, we've checked, if it's sunny, we've checked, if it's raining,

88
00:04:38,839 --> 00:04:40,359
we've checked if it's snowing.

89
00:04:40,609 --> 00:04:44,549
So if it's none of these three

90
00:04:45,609 --> 00:04:49,100
is going to be just a normal day, so else

91
00:04:49,220 --> 00:04:50,390
just dress normally.

92
00:04:51,950 --> 00:04:52,529
Ok.

93
00:04:53,290 --> 00:04:53,790
So

94
00:04:54,299 --> 00:04:57,959
the very first one here again is simply if else because there are two conditions.

95
00:04:58,250 --> 00:05:01,500
The second one here, we do have the else if statement because

96
00:05:01,670 --> 00:05:04,059
there is more than two conditions.

97
00:05:04,070 --> 00:05:08,350
In fact, there are four different results based on the weather.

98
00:05:08,630 --> 00:05:11,820
That's why we can no longer just work with the if else we have to introduce the

99
00:05:12,600 --> 00:05:14,570
if statement.

100
00:05:14,809 --> 00:05:17,470
So hopefully, you understand

101
00:05:17,970 --> 00:05:23,429
why we use the if else statement in here and why we used else if in here,

102
00:05:23,649 --> 00:05:28,709
if you don't, maybe hopefully once we begin to create actual programs

103
00:05:28,929 --> 00:05:31,959
using the algorithms, you will understand it much better then.

104
00:05:32,299 --> 00:05:37,380
But this has been an introduction to the world of algorithms as well as the if else,

105
00:05:37,390 --> 00:05:38,160
if statements.

106
00:05:38,170 --> 00:05:40,440
Thank you for watching. I will see you in the next class.

