1
00:00:01,190 --> 00:00:02,520
What's up my peeps.

2
00:00:02,520 --> 00:00:06,920
Mark Price you're at slow dot com in case you've forgotten.

3
00:00:07,020 --> 00:00:09,530
And hear new stuff and to my courses.

4
00:00:09,660 --> 00:00:11,390
You're going to hear that a lot.

5
00:00:11,550 --> 00:00:12,030
That's OK.

6
00:00:12,030 --> 00:00:14,080
You're going to learn to love it.

7
00:00:14,350 --> 00:00:16,950
It has some people who are like oh this rock and roll music.

8
00:00:16,950 --> 00:00:17,770
It's driving me crazy.

9
00:00:17,770 --> 00:00:19,440
You do it over and over and over again.

10
00:00:19,590 --> 00:00:22,500
But then everyone else is like this is so cool.

11
00:00:22,590 --> 00:00:26,430
It gets me motivated gets me excited gets the energy going because most of you guys are like doing this

12
00:00:26,430 --> 00:00:27,720
after work at night time.

13
00:00:27,720 --> 00:00:29,360
I'm doing a here near midnight.

14
00:00:29,400 --> 00:00:32,600
You've got to have something to wake you up and excite you about coding.

15
00:00:32,610 --> 00:00:36,150
If you find coding boring it doesn't have to be.

16
00:00:36,150 --> 00:00:36,780
OK.

17
00:00:37,080 --> 00:00:42,570
So that's my inspiration for the hour of course of course is this lesson is going to be that long.

18
00:00:42,570 --> 00:00:45,110
I hope we are going to go ahead and get started with the playground.

19
00:00:45,120 --> 00:00:51,690
And today we're going to finish our discussion on making conditional decisions and we're going to talk

20
00:00:51,690 --> 00:00:53,550
about logical operators today.

21
00:00:53,550 --> 00:00:57,460
We've talked about booleans right we've talked about if statements and statements.

22
00:00:57,900 --> 00:00:59,850
Those are called conditionals.

23
00:00:59,850 --> 00:01:04,520
Now we're going to talk about logical operators so logical operators.

24
00:01:04,520 --> 00:01:05,230
All right.

25
00:01:05,280 --> 00:01:09,260
Next time you go out on a date this this is what I want you to do.

26
00:01:09,300 --> 00:01:13,360
Be like hey you want to see my logical operators.

27
00:01:13,450 --> 00:01:18,460
Your day is going to be like this guy's awesome and this girl's cool.

28
00:01:19,050 --> 00:01:20,690
Serious do it all the time.

29
00:01:20,700 --> 00:01:21,740
All right.

30
00:01:23,360 --> 00:01:24,950
Don't do that.

31
00:01:24,950 --> 00:01:25,190
All right.

32
00:01:25,190 --> 00:01:25,730
Here we go.

33
00:01:25,730 --> 00:01:31,720
So I'm going to go here into our bulls and comparisons.

34
00:01:31,890 --> 00:01:37,660
Well call this logical operators a new folder.

35
00:01:37,660 --> 00:01:38,570
Here we go.

36
00:01:39,110 --> 00:01:39,380
OK.

37
00:01:39,380 --> 00:01:42,440
So again we've talked about true and false and everything else.

38
00:01:42,500 --> 00:01:49,130
Let's talk about how to make decisions and more decisions how to make more better decisions and one

39
00:01:49,130 --> 00:01:53,160
more I wanted to reemphasize on was that your unary operator.

40
00:01:53,270 --> 00:01:55,590
It's also a logical NOT operator.

41
00:01:55,610 --> 00:01:59,640
If that makes any sense so logical NOT operator.

42
00:01:59,800 --> 00:02:01,340
Sexually the way you say it.

43
00:02:01,670 --> 00:02:09,660
It's also a urinary a urinary prefix operator.

44
00:02:09,890 --> 00:02:12,920
Again those are just some terms for you there.

45
00:02:13,070 --> 00:02:14,330
So what is that.

46
00:02:14,330 --> 00:02:24,540
Well let me say allowed entry equals false and you.

47
00:02:24,630 --> 00:02:26,270
Like giving us an air.

48
00:02:26,420 --> 00:02:28,180
And so let what does it let.

49
00:02:28,220 --> 00:02:34,570
Let is a constant It means it cannot be changed so I cannot say allowed entry equals true.

50
00:02:34,700 --> 00:02:38,990
OK so you've got variables and you've got constants one you can change one you can't change it's all

51
00:02:38,990 --> 00:02:39,880
you've got to know about it.

52
00:02:39,960 --> 00:02:40,950
Pretty simple.

53
00:02:41,090 --> 00:02:45,520
OK so loud and true equals false.

54
00:02:45,550 --> 00:02:47,510
You can't get in right you can't get in the building.

55
00:02:47,540 --> 00:02:55,370
So if not allowed entry print access denied.

56
00:02:55,380 --> 00:03:03,020
All right so logical operator what it's really saying is it's the opposite of this.

57
00:03:03,020 --> 00:03:05,960
More or less so if allowed entry is true.

58
00:03:05,960 --> 00:03:10,850
Well we're not ask we're not doing that check we're saying if allowed entry is not true.

59
00:03:10,850 --> 00:03:15,790
So this would be the exact same thing as writing if allowed entry is not equal to true.

60
00:03:15,800 --> 00:03:19,050
That's the exact same thing except this is a little more writing right.

61
00:03:19,060 --> 00:03:24,410
One two three four five six different characters that you have to write are actually five more characters

62
00:03:24,410 --> 00:03:28,380
than you'd need to write on there plus the space anyway and it's long.

63
00:03:28,460 --> 00:03:32,540
So when you become a more veteran programmer you're going to start using this a lot more.

64
00:03:32,540 --> 00:03:37,760
Sometimes it makes sense to say this when you're new because it's easier to read ok and go ahead and

65
00:03:37,760 --> 00:03:38,490
do it from now on.

66
00:03:38,510 --> 00:03:40,250
You can feel free to do this.

67
00:03:40,340 --> 00:03:49,430
It's not equal to true but that the not operator is a quick shorthand way to say not OK if this is not

68
00:03:49,520 --> 00:03:50,090
true.

69
00:03:50,260 --> 00:03:51,060
OK.

70
00:03:51,640 --> 00:03:52,640
So that makes sense.

71
00:03:52,720 --> 00:03:56,200
OK just re-emphasizing that you're going to see a lot in other people's code.

72
00:03:57,250 --> 00:03:58,180
A step further.

73
00:03:58,340 --> 00:03:59,140
OK.

74
00:03:59,510 --> 00:04:04,220
Let again Constance you always want to use constants whenever you're not going to change the value if

75
00:04:04,220 --> 00:04:08,200
you are going to change the value is a variable but if you know you're not going to change the value

76
00:04:08,380 --> 00:04:10,540
is a constant memory optimized.

77
00:04:10,560 --> 00:04:12,640
Ok so very important use constants.

78
00:04:12,640 --> 00:04:16,300
At all possible entered door code.

79
00:04:16,330 --> 00:04:17,430
Oh OK.

80
00:04:17,450 --> 00:04:20,330
Now we're entering a door code equals true.

81
00:04:20,780 --> 00:04:21,610
OK.

82
00:04:21,860 --> 00:04:27,770
And let's say there's also a retina scan like it's like Metal Gear Solid OK.

83
00:04:28,070 --> 00:04:31,320
Past retina scan which was false.

84
00:04:31,340 --> 00:04:37,400
You know some high tech stuff you know or that game you'd like go and then back the original very first

85
00:04:37,400 --> 00:04:37,910
one.

86
00:04:37,910 --> 00:04:39,050
Is this the cause of the mall.

87
00:04:39,050 --> 00:04:43,910
I think you go knock on the crate and the really dumb AI would come running around and then after they

88
00:04:43,910 --> 00:04:46,940
felt like the noise was no longer threatening you know they would just chill

89
00:04:49,820 --> 00:04:50,840
it's irrelevant.

90
00:04:51,070 --> 00:04:51,660
OK.

91
00:04:51,780 --> 00:04:55,410
When it's midnight when you're making videos at midnight you can say whatever you want.

92
00:04:55,500 --> 00:05:01,020
And when you've got all these people watching you it's how it's going to be.

93
00:05:01,310 --> 00:05:03,240
Try and stop me.

94
00:05:03,240 --> 00:05:05,470
Camera isn't even here.

95
00:05:05,490 --> 00:05:13,020
Maybe if you we're here we're going to do is some We're going to use logical operators to make some

96
00:05:13,020 --> 00:05:19,170
decisions so let's say we want the user or the person is coming in to enter the door code and pass the

97
00:05:19,170 --> 00:05:20,830
retina scan.

98
00:05:20,970 --> 00:05:29,420
So what we're going to do is we're going to say if entered door code and past retinal scan.

99
00:05:29,850 --> 00:05:34,630
OK we're going to print welcome however.

100
00:05:34,890 --> 00:05:36,050
However.

101
00:05:36,120 --> 00:05:38,030
OK.

102
00:05:39,780 --> 00:05:45,120
Remember the movie Mission Impossible like they're reviewing You know the CIA bunker and how to get

103
00:05:45,120 --> 00:05:49,080
in the guy has to go through all the steps of the retinal scan they knew that they couldn't do it.

104
00:05:49,080 --> 00:05:50,660
So this is the way you do it.

105
00:05:50,700 --> 00:05:56,170
You enter door code and you do a retinal scan but so I say let.

106
00:05:56,610 --> 00:06:03,050
I am Tom Cruise from Mission Impossible.

107
00:06:03,240 --> 00:06:13,800
So if entered door code and past retina scan or if I am Tom Cruise for Mission Impossible then we can

108
00:06:13,800 --> 00:06:15,690
get in print welcome and sure enough.

109
00:06:15,690 --> 00:06:20,650
Mission Impossible Tom Cruise is in the door but of course I am not Tom Cruise.

110
00:06:20,830 --> 00:06:24,110
So this is what is this here.

111
00:06:24,110 --> 00:06:30,800
This is the logical or OPERATOR OK so what's going to happen is the right side is going to be calculated

112
00:06:30,800 --> 00:06:31,470
first here.

113
00:06:31,640 --> 00:06:33,530
OK.

114
00:06:33,530 --> 00:06:34,280
All right.

115
00:06:34,280 --> 00:06:40,050
And so if this is true OK it's going to be this or operator and then it doesn't even care about this.

116
00:06:40,280 --> 00:06:43,790
If this is true because or means one or the other has to be true.

117
00:06:43,850 --> 00:06:45,330
So this side's going to get run.

118
00:06:45,500 --> 00:06:49,500
And if that's true great otherwise or let's run this and then we do.

119
00:06:49,730 --> 00:06:52,240
If this is true and if this is true.

120
00:06:52,370 --> 00:06:52,690
OK.

121
00:06:52,700 --> 00:06:53,880
So then we.

122
00:06:53,990 --> 00:06:58,370
So we're at what we're saying here is hey both of these have to be true using the and operator here.

123
00:06:58,370 --> 00:07:00,360
So this is or this is.

124
00:07:00,390 --> 00:07:01,610
And OK.

125
00:07:01,760 --> 00:07:04,340
This is why it was printing when he was Tom Cruise.

126
00:07:04,340 --> 00:07:06,170
Right.

127
00:07:06,650 --> 00:07:11,220
Because the one on the right was true and do we need to care about this woman the left over here.

128
00:07:11,480 --> 00:07:13,060
So pretty cool huh.

129
00:07:13,250 --> 00:07:14,740
Also of course.

130
00:07:15,660 --> 00:07:18,320
So access is of course access is denied.

131
00:07:18,320 --> 00:07:18,600
OK.

132
00:07:18,620 --> 00:07:21,270
Because we haven't passed a retina scan yet.

133
00:07:21,340 --> 00:07:21,550
OK.

134
00:07:21,560 --> 00:07:28,460
So else or if you know the door code any pest redness redness scan or if I'm Tom Cruise from Mission

135
00:07:28,460 --> 00:07:32,950
Impossible or in else print

136
00:07:35,810 --> 00:07:39,900
Access Denied again.

137
00:07:40,280 --> 00:07:42,560
So print Access Denied again.

138
00:07:42,560 --> 00:07:42,770
All right.

139
00:07:42,770 --> 00:07:48,520
So what we've done here is before we just did NOT operator here we're doing an operator I mean these

140
00:07:48,530 --> 00:07:49,430
both have to be true.

141
00:07:49,430 --> 00:07:51,770
We also used an OR operator.

142
00:07:51,770 --> 00:07:55,400
So ORP your mission and Tom Cruise's Mission Impossible you're going to climb through and you're going

143
00:07:55,400 --> 00:07:56,890
to fall down through the roof.

144
00:07:56,880 --> 00:07:58,160
And you know you don't need the retina.

145
00:07:58,160 --> 00:08:00,230
You don't need a friggin retinas.

146
00:08:00,830 --> 00:08:01,040
All right.

147
00:08:01,040 --> 00:08:02,860
So cool stuff right.

148
00:08:03,220 --> 00:08:06,120
And let's do one more example of the OR operator here.

149
00:08:06,440 --> 00:08:09,130
When you say LET has a door key.

150
00:08:09,140 --> 00:08:12,820
It was false.

151
00:08:15,060 --> 00:08:19,760
So has Dorcy was false let knows over.

152
00:08:19,770 --> 00:08:22,010
Password equals true.

153
00:08:22,240 --> 00:08:30,660
OK then what we can do this is kind of like the Tom Cruise example right if has Dorcy or if knows override

154
00:08:30,660 --> 00:08:33,390
password and Prince.

155
00:08:33,560 --> 00:08:41,610
Welcome to the same thing or one or the other the right one is going to be processed first this nose

156
00:08:41,610 --> 00:08:45,330
over the password and that this is true and it doesn't mean to do anything with the left hand side if

157
00:08:45,330 --> 00:08:48,010
it is false then it's going to move to the left hand side over there.

158
00:08:48,150 --> 00:08:49,440
OK else

159
00:08:53,240 --> 00:09:03,030
you still ain't getting in you for whatever.

160
00:09:03,220 --> 00:09:03,690
Right.

161
00:09:03,860 --> 00:09:05,450
So and or.

162
00:09:05,470 --> 00:09:05,880
OK.

163
00:09:06,010 --> 00:09:07,290
Pretty cool right.

164
00:09:08,380 --> 00:09:12,460
So with these logical operators you can use parentheses there.

165
00:09:12,490 --> 00:09:13,370
You don't need to.

166
00:09:13,450 --> 00:09:16,110
OK they're optional but sometimes they help with readability.

167
00:09:16,140 --> 00:09:17,550
OK like this right here.

168
00:09:17,620 --> 00:09:18,300
This helps me a lot.

169
00:09:18,430 --> 00:09:20,440
Let me know that this is going to kind of run together.

170
00:09:20,680 --> 00:09:21,770
And this is over here.

171
00:09:21,850 --> 00:09:22,910
Sometimes people like to do that.

172
00:09:22,930 --> 00:09:27,120
You don't need to of course but they do work on that just fine.

173
00:09:27,640 --> 00:09:34,090
And we did used to and and as well as that or over here you can use logical operators in the same line.

174
00:09:34,090 --> 00:09:37,900
Really cool stuff you're going to use these a lot when you're making conditional you know conditional

175
00:09:37,900 --> 00:09:38,570
logic.

176
00:09:38,590 --> 00:09:42,400
That's how all programs are run you know and this is a perfect example right here.

177
00:09:42,550 --> 00:09:48,170
If you were actually building an app to well let's say you know even some phone apps or phones like

178
00:09:48,190 --> 00:09:51,700
they now have retinal scanning and stuff like to unlock the phone or even on the iPhone you can use

179
00:09:51,700 --> 00:09:58,330
your thumb you know so if the thumb print worked or you know if it detected your face you know then

180
00:09:58,330 --> 00:10:03,190
you're in you know lots of different options here and these are real real world examples that we're

181
00:10:03,190 --> 00:10:08,920
using here so logical operators are going to use them every single day it's going to take practice doing

182
00:10:08,920 --> 00:10:09,900
this here in the playground.

183
00:10:09,910 --> 00:10:13,100
It's OK but when you are actually building apps you it's really going to start to sink in.

184
00:10:13,120 --> 00:10:18,580
So really good stuff plowing along here in foundationless with hope you're learning a lot.

185
00:10:18,580 --> 00:10:20,030
Marc price at the Afro's.

