[python3/en] show that True and False are ints (#3412)

* [python3/en] show that True and False are ints

* [python3/en] rework some boolean stuff

I removed the example `-5 != False != True #=> True` because we didn't cover chaining yet.
This commit is contained in:
Niels Bom 2018-12-01 05:29:58 +01:00 committed by Divay Prakash
parent dd703e894e
commit 609abd3328

View File

@ -72,15 +72,24 @@ not False # => True
True and False # => False True and False # => False
False or True # => True False or True # => True
# Note using Bool operators with ints # True and False are actually 1 and 0 but with different keywords
# False is 0 and True is 1 True + True # => 2
True * 8 # => 8
False - 5 # => -5
# Comparison operators look at the numerical value of True and False
0 == False # => True
1 == True # => True
2 == True # => False
-5 != False # => True
# Using boolean logical operators on ints casts them to booleans for evaluation, but their non-cast value is returned
# Don't mix up with bool(ints) and bitwise and/or (&,|) # Don't mix up with bool(ints) and bitwise and/or (&,|)
bool(0) # => False
bool(4) # => True
bool(-6) # => True
0 and 2 # => 0 0 and 2 # => 0
-5 or 0 # => -5 -5 or 0 # => -5
0 == False # => True
2 == True # => False
1 == True # => True
-5 != False != True #=> True
# Equality is == # Equality is ==
1 == 1 # => True 1 == 1 # => True