Page 91 - Programming With Python 3
P. 91

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

               3|  print(10 == 10.0)
               4|  print("able" != "unable")
             Free

                    False
                    True
                    True
                    True
             eBook
                NOTE: An error will be thrown if you try to compare expressions that are of different types.


            This last example puts it all of the Boolean together, try running this program with several values of a:


               1|  a = int(input("enter an integer"))
               2|  print("a is", a)
             Edition
               3|  print("a is between 10 and 20 (inclusive)", a >= 10 and a <= 20)
               4|  print("a is greater than 100 or less than 3", a > 100 or a < 3)
               5|  print("a is 2 or 3 or between 20 and 30", a == 2 or a ==3 or (a
                       >= 20 and a <= 30))


                    a is 2
            Please support this work at
                    a is between 10 and 20 (inclusive) False
                    a is greater than 100 or less than 3 True
                    a is 2 or 3 or between 20 and 30 True
                                  http://syw2l.org



            Summary
                                                                               Free


            Goes here


            Important Terms



                                                                                  •
                                                                                      multiplication
                •   Boole                        •   compliment    eBook
                •   Boolean                      •   equal                        •   not
                •   False                        •   greater than                 •   not equal
                •   True                         •   greater than or equal        •   one
                •   addition                     •   less than                    •   or
                                                                Edition
                •   and                          •   less than or equal           •   zero







            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.
   86   87   88   89   90   91   92   93   94   95   96