What's up my peeps.
Mark Price you're at slow dot com in case you've forgotten.
And hear new stuff and to my courses.
You're going to hear that a lot.
That's OK.
You're going to learn to love it.
It has some people who are like oh this rock and roll music.
It's driving me crazy.
You do it over and over and over again.
But then everyone else is like this is so cool.
It gets me motivated gets me excited gets the energy going because most of you guys are like doing this
after work at night time.
I'm doing a here near midnight.
You've got to have something to wake you up and excite you about coding.
If you find coding boring it doesn't have to be.
OK.
So that's my inspiration for the hour of course of course is this lesson is going to be that long.
I hope we are going to go ahead and get started with the playground.
And today we're going to finish our discussion on making conditional decisions and we're going to talk
about logical operators today.
We've talked about booleans right we've talked about if statements and statements.
Those are called conditionals.
Now we're going to talk about logical operators so logical operators.
All right.
Next time you go out on a date this this is what I want you to do.
Be like hey you want to see my logical operators.
Your day is going to be like this guy's awesome and this girl's cool.
Serious do it all the time.
All right.
Don't do that.
All right.
Here we go.
So I'm going to go here into our bulls and comparisons.
Well call this logical operators a new folder.
Here we go.
OK.
So again we've talked about true and false and everything else.
Let's talk about how to make decisions and more decisions how to make more better decisions and one
more I wanted to reemphasize on was that your unary operator.
It's also a logical NOT operator.
If that makes any sense so logical NOT operator.
Sexually the way you say it.
It's also a urinary a urinary prefix operator.
Again those are just some terms for you there.
So what is that.
Well let me say allowed entry equals false and you.
Like giving us an air.
And so let what does it let.
Let is a constant It means it cannot be changed so I cannot say allowed entry equals true.
OK so you've got variables and you've got constants one you can change one you can't change it's all
you've got to know about it.
Pretty simple.
OK so loud and true equals false.
You can't get in right you can't get in the building.
So if not allowed entry print access denied.
All right so logical operator what it's really saying is it's the opposite of this.
More or less so if allowed entry is true.
Well we're not ask we're not doing that check we're saying if allowed entry is not true.
So this would be the exact same thing as writing if allowed entry is not equal to true.
That's the exact same thing except this is a little more writing right.
One two three four five six different characters that you have to write are actually five more characters
than you'd need to write on there plus the space anyway and it's long.
So when you become a more veteran programmer you're going to start using this a lot more.
Sometimes it makes sense to say this when you're new because it's easier to read ok and go ahead and
do it from now on.
You can feel free to do this.
It's not equal to true but that the not operator is a quick shorthand way to say not OK if this is not
true.
OK.
So that makes sense.
OK just re-emphasizing that you're going to see a lot in other people's code.
A step further.
OK.
Let again Constance you always want to use constants whenever you're not going to change the value if
you are going to change the value is a variable but if you know you're not going to change the value
is a constant memory optimized.
Ok so very important use constants.
At all possible entered door code.
Oh OK.
Now we're entering a door code equals true.
OK.
And let's say there's also a retina scan like it's like Metal Gear Solid OK.
Past retina scan which was false.
You know some high tech stuff you know or that game you'd like go and then back the original very first
one.
Is this the cause of the mall.
I think you go knock on the crate and the really dumb AI would come running around and then after they
felt like the noise was no longer threatening you know they would just chill
it's irrelevant.
OK.
When it's midnight when you're making videos at midnight you can say whatever you want.
And when you've got all these people watching you it's how it's going to be.
Try and stop me.
Camera isn't even here.
Maybe if you we're here we're going to do is some We're going to use logical operators to make some
decisions so let's say we want the user or the person is coming in to enter the door code and pass the
retina scan.
So what we're going to do is we're going to say if entered door code and past retinal scan.
OK we're going to print welcome however.
However.
OK.
Remember the movie Mission Impossible like they're reviewing You know the CIA bunker and how to get
in the guy has to go through all the steps of the retinal scan they knew that they couldn't do it.
So this is the way you do it.
You enter door code and you do a retinal scan but so I say let.
I am Tom Cruise from Mission Impossible.
So if entered door code and past retina scan or if I am Tom Cruise for Mission Impossible then we can
get in print welcome and sure enough.
Mission Impossible Tom Cruise is in the door but of course I am not Tom Cruise.
So this is what is this here.
This is the logical or OPERATOR OK so what's going to happen is the right side is going to be calculated
first here.
OK.
All right.
And so if this is true OK it's going to be this or operator and then it doesn't even care about this.
If this is true because or means one or the other has to be true.
So this side's going to get run.
And if that's true great otherwise or let's run this and then we do.
If this is true and if this is true.
OK.
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 here.
So this is or this is.
And OK.
This is why it was printing when he was Tom Cruise.
Right.
Because the one on the right was true and do we need to care about this woman the left over here.
So pretty cool huh.
Also of course.
So access is of course access is denied.
OK.
Because we haven't passed a retina scan yet.
OK.
So else or if you know the door code any pest redness redness scan or if I'm Tom Cruise from Mission
Impossible or in else print
Access Denied again.
So print Access Denied again.
All right.
So what we've done here is before we just did NOT operator here we're doing an operator I mean these
both have to be true.
We also used an OR operator.
So ORP your mission and Tom Cruise's Mission Impossible you're going to climb through and you're going
to fall down through the roof.
And you know you don't need the retina.
You don't need a friggin retinas.
All right.
So cool stuff right.
And let's do one more example of the OR operator here.
When you say LET has a door key.
It was false.
So has Dorcy was false let knows over.
Password equals true.
OK then what we can do this is kind of like the Tom Cruise example right if has Dorcy or if knows override
password and Prince.
Welcome to the same thing or one or the other the right one is going to be processed first this nose
over the password and that this is true and it doesn't mean to do anything with the left hand side if
it is false then it's going to move to the left hand side over there.
OK else
you still ain't getting in you for whatever.
Right.
So and or.
OK.
Pretty cool right.
So with these logical operators you can use parentheses there.
You don't need to.
OK they're optional but sometimes they help with readability.
OK like this right here.
This helps me a lot.
Let me know that this is going to kind of run together.
And this is over here.
Sometimes people like to do that.
You don't need to of course but they do work on that just fine.
And we did used to and and as well as that or over here you can use logical operators in the same line.
Really cool stuff you're going to use these a lot when you're making conditional you know conditional
logic.
That's how all programs are run you know and this is a perfect example right here.
If you were actually building an app to well let's say you know even some phone apps or phones like
they now have retinal scanning and stuff like to unlock the phone or even on the iPhone you can use
your thumb you know so if the thumb print worked or you know if it detected your face you know then
you're in you know lots of different options here and these are real real world examples that we're
using here so logical operators are going to use them every single day it's going to take practice doing
this here in the playground.
It's OK but when you are actually building apps you it's really going to start to sink in.
So really good stuff plowing along here in foundationless with hope you're learning a lot.
Marc price at the Afro's.