Boolean data type has only two values - True and False
True
False
Like other values, boolean values can be used in expressions and variable. But write them with a capital T and F
spam = True
spam
Operator | Meaning |
---|---|
== | Equal to |
!= | Not equal to |
< | Less than |
> | Greater than |
<= | Less than or equal to |
> | Greater than or equal to |
Expressions with comparison operators evaluate to Boolean values.
42 == 42
8 > 9
8 > 8
8 >= 8
42 < 42
Number = 42
42 == Number
100 < Number
Integers and strings will always not be equal to each other.
42 == '42'
42 == int('42')
Float values and integer values can be equal to each other.
42.0 == 42
Single = (=) is a variable assignment operator
Double = (==) is equal to operator.
True and True
True and False
False and True
False and False
False or False
True or False
False or True
True or True
not True
not False
Number = 42
string = 'spam'
Number > 10 and string == 'spam'