Learn Python Episode #10: Boolean Operators

preview_player
Показать описание

In this video we're going to be talking about Boolean operators. So, what is a Boolean? This is a general programming concept, and a Boolean consists of two items - true and false. Basically, truth checking. So, let's have a look at some of the ways we can generate a true or false. Let's start with 5=5. In math terms this is true, but a single equal sign is used to assign a value to a variable in Python. When comparing two numbers or strings you will need to use double equal signs like so.

5==5

Python will return True. If we try 5==4, Python will return False. We can also write the following:

5 is 5

Python will return True. If we were to write 5 is 4, Python will return False. Similarly, 5 is not 4 will return True. We can also compare strings.

"I like pizza"=="I like pizza"

Python will return true. In the next video we will cover Python's version of arrays which are called lists.

Рекомендации по теме
Комментарии
Автор

I personally like to use assert(value == something), to see if it holds up. If it does, nothing happens. If it doesn't, Python 'freaks out', as you said and spits out an AssertionError :P

jager
Автор

Sir, I am getting syntax warning, while there is no such warning on your system, plz explain :
"This" is "This"
<input>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
<input>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True

radhagogia
Автор

in my opinion it's better to chose a project before starting to just learn this theoretic stuff when beginning with a programming language.(sorry for my bad english)

nqugbhi
Автор

how do you do this in windows? I tried using the terminal in pycharm but no response

xboxlive