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