1
00:00:00,730 --> 00:00:00,980
Hello.

2
00:00:01,000 --> 00:00:01,980
Welcome back.

3
00:00:01,990 --> 00:00:05,770
In this lesson we shall take a look at conditions and loops.

4
00:00:05,770 --> 00:00:07,210
So this was our last lesson.

5
00:00:07,210 --> 00:00:10,800
We can create a new script by clicking follow here.

6
00:00:10,900 --> 00:00:16,090
New file and then we are going to press control and as to save and save.

7
00:00:16,090 --> 00:00:17,960
This is number four on this score.

8
00:00:17,950 --> 00:00:25,010
Conditions conditions on the score loops like this.

9
00:00:25,150 --> 00:00:28,370
Once that's done we conclude this one over here.

10
00:00:28,620 --> 00:00:31,920
Open this a bit right.

11
00:00:32,140 --> 00:00:36,830
So let's see how to create some loops and conditions.

12
00:00:36,850 --> 00:00:43,770
Let's start with a simple example I'm going to declare a string let's say city of course I call this

13
00:00:43,770 --> 00:00:48,820
city London like this and I could see it down here.

14
00:00:48,820 --> 00:00:49,660
Temperature

15
00:00:53,620 --> 00:00:55,800
equals 35.

16
00:00:55,850 --> 00:01:02,130
I could say something like this and over here I could come and see the first condition.

17
00:01:02,140 --> 00:01:11,560
So like in any program language condition uses the if statement in Python we say if city and then we

18
00:01:11,560 --> 00:01:18,970
compare city to what we want to compare to equal to equal to then report the second operant which is

19
00:01:18,970 --> 00:01:20,320
London.

20
00:01:21,100 --> 00:01:24,340
And can we use and it and D.

21
00:01:24,420 --> 00:01:27,970
And here we don't use the undersigned sign.

22
00:01:28,150 --> 00:01:32,980
So we say if city course London and term preacher

23
00:01:35,830 --> 00:01:38,440
because in course 35.

24
00:01:39,220 --> 00:01:40,590
So this condition reads.

25
00:01:40,690 --> 00:01:45,630
If city of course London and temperature equals that 5.

26
00:01:45,880 --> 00:01:54,190
If this condition is true we put column hit Enter colon enter and then what we want to execute if this

27
00:01:54,190 --> 00:01:57,400
condition is true we can say then print

28
00:02:00,740 --> 00:02:03,050
it is hot in London today.

29
00:02:03,050 --> 00:02:03,860
Something like that.

30
00:02:03,980 --> 00:02:09,110
I could just see it as hope in London today

31
00:02:11,810 --> 00:02:19,660
like this and if we want to put an L statement we go out of the indentation.

32
00:02:19,660 --> 00:02:26,840
Come back here and see L's put a semicolon hit enter an imprint.

33
00:02:26,950 --> 00:02:27,700
Something like

34
00:02:31,620 --> 00:02:32,430
it's just fine.

35
00:02:32,440 --> 00:02:33,100
How about that.

36
00:02:33,590 --> 00:02:33,970
It's

37
00:02:37,840 --> 00:02:40,120
just fine like this.

38
00:02:40,120 --> 00:02:43,080
So let's try this out and see what we get currently.

39
00:02:43,090 --> 00:02:46,560
Temperatures that 5 and the cities London.

40
00:02:46,560 --> 00:02:52,480
So the condition should be true we should get this first statement of press control as to save quick

41
00:02:52,510 --> 00:02:55,210
run run module.

42
00:02:55,210 --> 00:02:56,520
This is what we get.

43
00:02:56,560 --> 00:02:58,410
It is hot in London today.

44
00:02:58,410 --> 00:03:06,040
That's how I changed the temperature to 30 control s run run module.

45
00:03:06,100 --> 00:03:07,420
It's just fine.

46
00:03:07,420 --> 00:03:12,120
So this how to create a simple condition if you operations comparison here.

47
00:03:12,280 --> 00:03:19,960
If you want to use and you type and a n d and then this lets look at another operator.

48
00:03:20,210 --> 00:03:22,940
That's the word in I n the operator.

49
00:03:22,960 --> 00:03:26,810
In fact I'll put a comment here to an operator.

50
00:03:27,100 --> 00:03:28,640
We're going to look at this.

51
00:03:29,500 --> 00:03:35,250
OK so let's do another example let's say city cores hobo.

52
00:03:35,340 --> 00:03:38,610
A place like Mumbai.

53
00:03:38,610 --> 00:03:50,930
This is city course Mumbai and we can see if city in and what we have to do here what we're going to

54
00:03:50,930 --> 00:03:53,760
do it is create a list of cities actually.

55
00:03:53,800 --> 00:04:01,220
So to create a list of cities we can just see if city in and then in these cities we are about right.

56
00:04:01,280 --> 00:04:10,310
New York comma Accra through this one in through Istanbul

57
00:04:14,940 --> 00:04:18,030
come out with through London.

58
00:04:18,080 --> 00:04:18,530
Others.

59
00:04:18,560 --> 00:04:19,870
This is enough typing.

60
00:04:19,880 --> 00:04:26,740
So if city in New York Accra Istanbul right.

61
00:04:26,900 --> 00:04:34,710
If if Citi in this list of cities will personally call on a friend

62
00:04:38,390 --> 00:04:40,260
city phoned.

63
00:04:41,170 --> 00:04:45,470
Put exclamation here like this one.

64
00:04:45,500 --> 00:04:46,470
No statesmanship.

65
00:04:46,500 --> 00:04:46,970
Else

66
00:04:49,940 --> 00:04:51,410
semicolon.

67
00:04:51,470 --> 00:04:56,800
Print city not font right.

68
00:04:58,680 --> 00:05:05,100
So let's run this and see this condition will be checked if temperature indeed is equal to 55.

69
00:05:05,100 --> 00:05:06,120
We're going to receive.

70
00:05:06,220 --> 00:05:10,810
Hot in London if not if that's not the case it's going to say it's just fine.

71
00:05:10,810 --> 00:05:13,350
So we're going to see one of these statements printed after that.

72
00:05:13,360 --> 00:05:19,010
This condition would check us well and we'll find whether city found or city not found.

73
00:05:19,030 --> 00:05:21,860
So let's click here to run and see what we've got.

74
00:05:21,940 --> 00:05:23,490
Click okay.

75
00:05:23,680 --> 00:05:27,680
It's just fine because temperature indeed it's not.

76
00:05:27,680 --> 00:05:35,290
That's five cities no phone because city here which is Mumbai it's not in this list and to show you.

77
00:05:35,770 --> 00:05:39,390
Let's just put Mumbai here.

78
00:05:39,400 --> 00:05:42,470
Control s click over here.

79
00:05:42,520 --> 00:05:45,510
Run module and now he says city found.

80
00:05:45,520 --> 00:05:46,630
So this very simple.

81
00:05:46,780 --> 00:05:54,610
This is very simple with such this entire list just by this simple line of code and these five strings

82
00:05:54,640 --> 00:05:57,810
right we didn't need to do any special stuff.

83
00:05:57,820 --> 00:05:58,040
OK.

84
00:05:58,060 --> 00:06:04,800
Let's see on that example how about rather than having the list of the list over here.

85
00:06:04,930 --> 00:06:11,470
Let's throw the list in a variable and then such that list that variable and then see if it produces

86
00:06:11,470 --> 00:06:13,180
the same result.

87
00:06:13,180 --> 00:06:13,450
OK.

88
00:06:13,470 --> 00:06:16,390
I'm going to come down here and see countries

89
00:06:19,030 --> 00:06:19,510
because

90
00:06:22,540 --> 00:06:23,800
two key

91
00:06:27,250 --> 00:06:27,910
Kano

92
00:06:31,310 --> 00:06:31,970
China

93
00:06:36,200 --> 00:06:38,940
and let's through in India here.

94
00:06:39,620 --> 00:06:42,650
And we can come here and see concrete.

95
00:06:42,680 --> 00:06:48,460
Perhaps the country we're looking for is Turkey like this.

96
00:06:51,380 --> 00:06:53,390
So it's the same example.

97
00:06:53,390 --> 00:06:56,630
This time we can see if country

98
00:06:59,060 --> 00:07:00,770
in countries

99
00:07:06,170 --> 00:07:06,770
print

100
00:07:11,610 --> 00:07:15,950
country found.

101
00:07:15,960 --> 00:07:20,100
Remember now we've got both of them represented in variables.

102
00:07:20,130 --> 00:07:24,660
So we've got this list of countries stored in this variable called countries and then we've got this

103
00:07:24,660 --> 00:07:28,510
single country variable which Turkey is assigned to.

104
00:07:28,570 --> 00:07:36,580
We've seen if country in countries meaning if country if Turkey in this list then print country found.

105
00:07:36,670 --> 00:07:37,710
So let's see what we have

106
00:07:43,960 --> 00:07:48,720
or just click here to run and indeed country found.

107
00:07:48,780 --> 00:07:49,560
Right.

108
00:07:49,560 --> 00:07:53,290
So this is how to use conditions and loops.

109
00:07:53,610 --> 00:07:54,300
Very simple.

110
00:07:54,300 --> 00:07:56,600
We shall see more examples as we get to them.

111
00:07:56,620 --> 00:08:02,340
The other variations which we or touch on but this the basics this all you need to know at this point.

112
00:08:02,430 --> 00:08:05,100
So do you have any questions at all.

113
00:08:05,100 --> 00:08:08,670
Just send me a message and I'll get back to you very quickly.

114
00:08:08,790 --> 00:08:13,230
And if you're enjoying the course please take some time off to leave a review that's all there is for

115
00:08:13,230 --> 00:08:14,750
now and have a good day.
