‫All right.
‫In this video, I'm going to try and trick you.
‫I want you to look at these expressions where I'm checking for equality.
‫Right.
‫I'm saying, hey, does true equal for one?
‫Does empty string equal one do to erase equal that are empty equal.
‫Well each other.
‫Now pause the video here and try to guess what the outcomes of this are going to be.
‫Ready.
‫By the way, if you get 100% on this.
‫Well, good for you, because if this was my first time learning Python, I wouldn't get this.
‫Let's go.
‫Hmm.
‫Is that why you expected?
‫True.
‫Evaluated so true equals want evaluated to true.
‫An empty string equals to one evaluated to false.
‫That makes sense because they definitely don't equal each other.
‫Right?
‫An empty array doesn't equal to one.
‫And a ten equals 10.0.
‫And then both the race that are empty.
‫Equal to true.
‫Now, the reason I'm showing you here is that the double equals checks for equality or equality of value.
‫That is, if, for example, the first one true equals to one.
‫There's two different types.
‫One's an integer, one's a bullion.
‫It will convert them into the same type.
‫In this case, this will be converted like this to a boolean value.
‫And if you remember, one is truth.
‫So this will evaluate to true, which is why we get true.
‫What about the other one?
‫Well, an empty string is falsely, so it evaluates to false.
‫And false doesn't equal true.
‫Right.
‫Because we're checking for equality here.
‫So one of these gets converted to the other type.
‫What about an empty array?
‫Again, an empty array is actually falsely.
‫So that's not going to equal one.
‫A ten equals to a float of 10.0.
‫That gets converted to an integer or float and they're going to equal each other.
‫And that's an expected behavior.
‫And then an empty array, well, equals an empty array.
‫If I add in this array, one, two, three, one, two, three and I click run.
‫I get an invalid syntax because I have this here.
‫Let's run that again.
‫I get true.
‫That makes sense.
‫Let's change this to one and see what happens if I click Run.
‫All right.
‫Still false.
‫Now, this does get a little tricky, right?
‫Like.
‫Hmm.
‫Should this have evaluated to true?
‫But no, we get false.
‫So this doesn't get converted in type versus what we had here.
‫Now, don't get confused by this because this would be bad code if you're checking something like this.
‫Well, obviously you should be checking two types, two of the same types together.
‫Ideally, when you use comparison operators or logical operators like this, you're comparing two types
‫and you're not letting Python do this type conversion.
‫And hopefully Python figures it out for us.
‫But I hope the double quality makes sense because there's another check that we can do, which is is
‫and is well is a keyword and python.
‫What happens if we change all these equal signs to is.
‫Do you think there would be a difference?
‫Let's have a look.
‫If I click Run.
‫I get false for everything.
‫Hmm.
‫So what's the difference here?
‫Equals checks for the equality in value.
‫Such as?
‫One, two, three.
‫Well, that's has the same value as one, two, three.
‫In a list is actually checks.
‫If the location in memory where this value is stored is the same.
‫Hmm.
‫Let's go through that.
‫So true.
‫Is that one note true is not one true is well only true rate that will be true.
‫What about.
‫String one.
‫Is that one?
‫No.
‫I mean, for one to be a string, that needs to be one, right?
‫Because the one string isn't only in one place in memory.
‫It's literally the exact same thing.
‫What about this list?
‫As a matter of fact, let's do is array, empty array?
‫Is that or is this list a list?
‫Well, if we run this.
‫I still get false.
‫Hmm.
‫And this is a little tricky and also advanced.
‫Every time I create a list, it's added in memory somewhere.
‫So this is in a location in memory.
‫But whenever I create a new list.
‫It's created in another location.
‫So these are two completely different lists that live in different locations in memory.
‫So it's going to check, hey, is this in the same memory space, same bookshelf as that one?
‫No, that's not it.
‫But why does this work for things like numbers and strings?
‫And that's because underneath the hood, these are types that are very simple, that are in memory,
‫but in one location versus something like a list, even though this might be the same list with the
‫same items.
‫Because this is a data structure.
‫Every time we create it, it's created in a new location so that even if we have a variable A that contains.
‫This list.
‫And by the way, this will be the same for all our data structures like dictionaries, sets, tuples.
‫If I do B equals this and I check A, is that B?
‫Nope.
‫They're created in a different memory space.
‫So this where a points is in a different place than where B points.
‫But if I do A equals to be.
‫I get true because this double equality checks.
‫Only the valleys.
‫Now this is a bit of a hard topic, so you might have to watch this video a couple of times.
‫You might have to practice this a few times yourself.
‫But just keep in mind the difference between IS and double equals is tends to be a little stricter.
‫You're checking for the exact thing that you're looking for versus equality, which checks the value.
‫All right.
‫That was a doozy.
‫I'll see you in the next video.
‫Bye bye.