Академический Документы
Профессиональный Документы
Культура Документы
then depending on answers to these yes/no questions can move around until finally
you get the end box.
You can just keep making them longer and larger and larger.
But the boolean datatype only has these two values:True and False.
Like any other value boolean values are used in expressions and can be stored in
variables.
42 is equal to 42.
That's also False. You know can also check with the "not equal to" operator.
But 42
make them as complicated as we want. we can use variables say, myAge equals 30...
uh...
always *not* be equal to each other. If you have the string '42' and the integer
42, those aren't going to be same.
You might have noticed that the "equal to" operator has choose equal signs and it
will be variable assignment operator just has
the comparison "is equal to" operator as being two characters just like how the
"is not equal to" operator is two
characters: the explanation point
You might have used them in search engines. Let's do some experiments in the
interactive shell with the
So something like "True and True" will evaluate to True, but it one or both but
these are False,
There's a concept called truth tables that numerate every possible combination.
of these two values: True and True evaluates to True and otherwise it's False.
The or operator will evaluate to true if either or both of the values are True. As
long as it's not
is True. The only time that it's False is when both of them are False.
Here's the truth table for "or": Everything is True except for "False or False"
which evaluates to False.
And then the "not" operator just evaluates to the opposite boolean value. "not
True" is False
"and" and "or" operators, the "not" operator only operates on one boolean value. So
its truth table is
fairly simple. You'll often mix boolean and comparison operators together in the
same expression.
Then we can have a complicated expression like myAge > 20 and myPet == 'cat'.
This evaluates to True because both parts on either side of the "and" operator
evaluate to True.
The six comparison operators are: equal to, not equal to,
both of them are False. And the "not" operator simply evaluates to the opposite
boolean value.