Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
In this video I'm going to talk about the idea of truthiness and falsely What did they mean.
And you'll hear this a lot in Python programming you see.
Up until now you've used billions here as values.
So it was really easy.
If true and true then run this code but Python can do other things as well.
For example if this was five and this was let's say hello what do you think will happen here in our
program.
Well if I click Run you are old enough to drive and you have a license.
Is that what you expected.
And this is because what Python does underneath the hood is actually convert these to billions for you.
So it's almost as if it is doing this remember type conversion where converting the type to boolean
as soon as we get to this if statement because python is saying hey I want true or false I don't care
what is old is I don't care what is license this just give me true or false.
So I know whether to do this or to go to the else block.
Now if I was to just print let's do this here let's do print boolean Hello.
And then finally print boolean 5.
Let's see what we get we get true true.
And this is what we call a truth the value in python that is it's a truth value because if we run the
boolean type conversion on it it evaluates into true what's a false value.
Well if I do zero and if I do let's say an empty string and I click run those are false.
That is it's not actually false but it is false see because if we run bullion on it to Python it's going
to say oh this is false and zero.
That's false.
And that kind of makes sense right.
And if you actually go to stack overflow.
If you've never seen stack overflow before.
If you ever have programming questions and you're Googling them usually the top five answers will contain
either one or two stack overflow answers.
And basically what happens is people ask questions like What is truth and falsity in Python and you
get answers so you can see over here that it has four answers and you usually look for the checkmark
which means that this is a verified answer and means that hey this question owner has accepted it as
the best answer.
So the person who asked this question just said Yep this is the right answer.
This is the best one.
But you also have other people voting so you can see that this answer received 46 marks and although
it was marked as the correct answer by the user maybe somebody else came along later on and gave an
even better answer.
So now we have one hundred and twenty three upvotes and you see that this answer is a lot better all
values are considered toothy except for the following so you can actually see here that in Python these
values are considered false see you can see 0 here you can see an empty string here and then there's
a few other ones empty set.
You have a empty dictionary empty list empty tuple you have decimals you have things like fractions
you have zero point zero false is that and also none is false.
So that if I type in none here that's false to now you don't need to memorize these because most of
the time it it makes sense right.
But it helps us do conditional logic very nicely.
For example let's remove this and let's say that we have a user and this user has to have a password
and a user name if let's say they user name is Johnny and the password is 1 2 3 well instead of me saying
hey if this user has password and username and we're not checking if the user name exists or password
exists we just want to make sure hey did this person fill out the form and did they try to submit a
user name and password.
I can just simply say password and username and I don't have to worry about converting this to a Boolean
or anything like that because if password and user name exist then tried to log them in and you see
that it reads a lot nicer because each one of these get evaluated into a true and false C value it's
a nice little feature to keep Python well nice and simple and reading like English I'll see 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.