Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. >>> # Boolean Expressions >>> x = 5 >>> y = 6 >>> x == 5 True >>> not x == 5 False >>> x == 6 False >>> not x == 6 True >>> # distinguish "not" from "!=" >>> x = 6 >>> not x == 6 False >>> x !=6 False >>> not x != 6 True >>> # expressions can be complex >>> x = 5 >>> y = 6 >>> (x == 5) and (y == 6) True >>> (x == 5) and (y == 5) False >>> (x == 0) and (y == 0) False >>> True and True True >>> True and False False >>> False and False False >>> # let's look at "or" >>> tall = True >>> woman = True >>> short = False >>> man = False >>> # >>> tall or short True >>> man or woman True >>> tall or woman True >>> short or man # only if both are False is the result False False >>> ## longer expressions >>> (False or True) and (False or True) True >>> (false and False) or (False or True) Traceback (most recent call last): File "", line 1, in (false and False) or (False or True) NameError: name 'false' is not defined >>> (False and False) or (False or True) True >>> ## True is stored as 1; False is stored as 0 >>> ## So, we have this kind of weird test >>> False < True True >>> True < False False >>> # but you won't use them like that >>>