Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108135
| From | Bob Gailer <bgailer@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Conditionals And Control Flows |
| Date | 2016-05-04 10:54 -0400 |
| Message-ID | <mailman.385.1462373653.32212.python-list@python.org> (permalink) |
| References | <f12b6c42-8edb-4f91-8994-7c122e99461e@googlegroups.com> <CAP1rxO4y_vz6h+s3KKC5V8b3U8O_QnvDhAC6sxOuHi6QnWuWrg@mail.gmail.com> <CAP1rxO5rQEtNQksp25YkARo1pYBBiQjOTY5vVCjZ5Hg4-KAehg@mail.gmail.com> |
On May 4, 2016 10:45 AM, "Cai Gengyang" <gengyangcai@gmail.com> wrote: > > I am trying to understand the boolean operator "and" in Python. It is supposed to return "True" when the expression on both sides of "and" are true > > For instance, > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > bool_one = False and False --- This should give False because none of the statements are False > bool_two = True and False --- This should give False because only 1 statement is True > bool_three = False and True --- This should give False because only 1 statement is True > bool_five = True and True --- This should give True because only 1 statement is True > > Am I correct ? Yes. Caveat : python Boolean operators return the value of the last argument necessary to determine the outcome. Example : 2 or 3 results in 2 2 and 3 results in 3. 0 and 3 results in 0. HTH.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Conditionals And Control Flows Cai Gengyang <gengyangcai@gmail.com> - 2016-05-04 07:41 -0700
Re: Conditionals And Control Flows Bob Gailer <bgailer@gmail.com> - 2016-05-04 10:54 -0400
Re: Conditionals And Control Flows Michael Selik <michael.selik@gmail.com> - 2016-05-04 14:56 +0000
Re: Conditionals And Control Flows Chris Angelico <rosuav@gmail.com> - 2016-05-05 00:58 +1000
Re: Conditionals And Control Flows Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-04 18:10 +0300
Re: Conditionals And Control Flows Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-04 16:21 +0100
Re: Conditionals And Control Flows Cai Gengyang <gengyangcai@gmail.com> - 2016-05-04 08:23 -0700
Re: Conditionals And Control Flows Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-04 19:41 +0300
Re: Conditionals And Control Flows Stephen Hansen <me+python@ixokai.io> - 2016-05-04 11:54 -0700
csiph-web