mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
[python/en] Added Bool operators
Bool operators
This commit is contained in:
parent
9a909d6a4a
commit
62f4c0de22
@ -57,9 +57,17 @@ to Python 2.x. Look for another tour of Python 3 soon!
|
|||||||
# Enforce precedence with parentheses
|
# Enforce precedence with parentheses
|
||||||
(1 + 3) * 2 # => 8
|
(1 + 3) * 2 # => 8
|
||||||
|
|
||||||
# Boolean values are primitives
|
# Boolean Operators
|
||||||
True
|
+# Note "and" and "or" are case-sensitive
|
||||||
False
|
+True and False #=> False
|
||||||
|
+False or True #=> True
|
||||||
|
+
|
||||||
|
+# Note with ints
|
||||||
|
+0 and 2 #=> 0
|
||||||
|
+-5 or 0 #=> -5
|
||||||
|
+0 == False #=> True
|
||||||
|
+2 == True #=> False
|
||||||
|
1 == True #=> True
|
||||||
|
|
||||||
# negate with not
|
# negate with not
|
||||||
not True # => False
|
not True # => False
|
||||||
|
Loading…
Reference in New Issue
Block a user