Page 90 - Programming With Python 3
P. 90

An Introduction to STEM Programming with Python — 2019-09-03a                               Page 77
            Chapter 6 — Boolean

               3|          for c in [False,True]:
               4|              print(a, b, c, (a and b or not(b and c)) and (a and
             Free
                       c or not(c)))

                    False False False True
                    False False True False
                    False True False True
                    False True True False
             eBook
                    True False False True
                    True False True True
                    True True False True
                    True True True True

            It is interesting to note in the example above, that the final column is the same as the AC+C' column
             Edition
            and that this simpler expression is exactly the same.


            Comparing Two Values in Python



            Comparison operators look at two values and return True or False depending on the values. The siz
            Please support this work at
            most commonly used ones are:
                    == — Equal.
                    != — Not Equal.
                                  http://syw2l.org
                    <= — Less than or equal.
                    >= — Greater than or equal.
                    < — Less than.
                                                                               Free
                    > — Greater than.



             ==  !=  <  <=  >  >=                                                      Comparison Operators
             The comparison operators of equal, not equal, less than, less than or equal,
                                                                   eBook
             greater than, and greater than or equal.

             https://docs.python.org/3/reference/expressions.html#comparisons
             http://bit.ly/2FeNJVk



                                                                Edition
            An example of comparing some values, follows:


               1|  print(10 < 10)
               2|  print(10 <= 10)


            Copyright 2019 — James M. Reneau Ph.D. — http://www.syw2l.org — This work is licensed
            under a Creative Commons Attribution-ShareAlike 4.0 International License.
   85   86   87   88   89   90   91   92   93   94   95