All language subtitles for 9. is vs ==

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

All right.

In this video I'm going to try and tricky.

I want you to look at these expressions where I'm checking for equality right.

I'm saying hey does true equal four one does empty string equal one due to race equal that are empty

equal while each other now pause a video here and try to guess what the outcomes of this are going to

be.

Ready.

By the way if you get one hundred percent on this wall.

Good for you because if this was my first time learning python I wouldn't get this.

Let's go home.

Is that why you expected true evaluated so true because one evaluated to true an empty string.

It goes 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 10 equals ten point zero and then both arrays 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 on true equals to one there's two different types one's an integer

one's a boolean 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 on empty string is false see 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's type.

What about an empty array.

Again an empty array is actually false see so that's not going to equal one a ten equals to a float

of ten point 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 year 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.

Mm hmm.

Should this have evaluated too.

True but now we get false so this doesn't get converted in time vs. 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 W quality makes sense because there's another check that we can do which is is and is

well as a keyword in Python.

What happens if we change all these equal signs to is do you think there will be a difference.

Let's have a look.

If I click Run I get false for everything.

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 and memory

where this value is stored is the same.

Let's go through that.

So true is that one note true is not one true is while only true.

Right.

That will be true.

What about string one is that one.

No.

I mean for one to be a shrink 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 lists two is array empty array.

Is that or is this list a list.

Well if we run this I still get false

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 topples.

If I do B equals this and I check a is that B No 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 b I get true because this double equality checks only the values.

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 E 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.

Clancy in the next video by.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.