Re: Boolean Expressions

2017-09-28 Thread Joel Goldstick
On Wed, Sep 27, 2017 at 5:21 AM, Cai Gengyang wrote: > On Wednesday, September 27, 2017 at 1:01:50 PM UTC+8, Cameron Simpson > wrote: > > On 26Sep2017 20:55, Cai Gengyang wrote: > > >On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson > wrote: > > >> On 26Sep2017 14:43, Cai Gen

Re: Boolean Expressions

2017-09-27 Thread Cai Gengyang
On Wednesday, September 27, 2017 at 1:01:50 PM UTC+8, Cameron Simpson wrote: > On 26Sep2017 20:55, Cai Gengyang wrote: > >On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: > >> On 26Sep2017 14:43, Cai Gengyang wrote: > >> >C) Set bool_three equal to the result of > >> >

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
On 26Sep2017 20:55, Cai Gengyang wrote: On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: On 26Sep2017 14:43, Cai Gengyang wrote: >C) Set bool_three equal to the result of >19 % 4 != 300 / 10 / 10 and False > 19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the

Re: Boolean Expressions

2017-09-26 Thread Gregory Ewing
Cai Gengyang wrote: So does that mean that the way 'and' works in Python is that both terms must be True (1) for the entire expression to be True ? Why is it defined that way, weird ? It's not weird, it's the normal meaning of "and" in English. Do I have purple hair? No. Do I have three nostri

Re: Boolean Expressions

2017-09-26 Thread Cai Gengyang
On Wednesday, September 27, 2017 at 6:45:00 AM UTC+8, Cameron Simpson wrote: > On 26Sep2017 14:43, Cai Gengyang wrote: > >Help check if my logic is correct in all 5 expressions > > Why not just run some code interactively? Unless this is entirely a thought > exercise to verify that you have a so

Re: Boolean Expressions

2017-09-26 Thread Steve D'Aprano
On Wed, 27 Sep 2017 08:23 am, Cai Gengyang wrote: > > I'm trying to understand the logic behind AND. I looked up Python logic tables > > False and False gives False > False and True gives False > True and False gives False > True and True gives True. > > So does that mean that the way 'and' wor

Re: Boolean Expressions

2017-09-26 Thread Thomas Jollans
On 27/09/17 00:23, Cai Gengyang wrote: > I'm trying to understand the logic behind AND. I looked up Python logic tables > > False and False gives False > False and True gives False > True and False gives False > True and True gives True. > > So does that mean that the way 'and' works in Python is t

Re: Boolean Expressions

2017-09-26 Thread Irv Kalb
> > On Sep 26, 2017, at 3:23 PM, Cai Gengyang wrote: > > > I'm trying to understand the logic behind AND. I looked up Python logic tables > > False and False gives False > False and True gives False > True and False gives False > True and True gives True. > > So does that mean that the way 'a

Re: Boolean Expressions

2017-09-26 Thread Irmen de Jong
On 09/27/2017 12:23 AM, Cai Gengyang wrote: > > I'm trying to understand the logic behind AND. I looked up Python logic tables > > False and False gives False > False and True gives False > True and False gives False > True and True gives True. > > So does that mean that the way 'and' works in P

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
On 26Sep2017 15:23, Cai Gengyang wrote: I'm trying to understand the logic behind AND. I looked up Python logic tables False and False gives False False and True gives False True and False gives False True and True gives True. So does that mean that the way 'and' works in Python is that both

Re: Boolean Expressions

2017-09-26 Thread Cameron Simpson
On 26Sep2017 14:43, Cai Gengyang wrote: Help check if my logic is correct in all 5 expressions Why not just run some code interactively? Unless this is entirely a thought exercise to verify that you have a solid mental understanding of Python semantics, all your reasoning is easy to test.

Re: Boolean Expressions

2017-09-26 Thread Rob Gaddi
On 09/26/2017 03:23 PM, Cai Gengyang wrote: I'm trying to understand the logic behind AND. I looked up Python logic tables False and False gives False False and True gives False True and False gives False True and True gives True. So does that mean that the way 'and' works in Python is that bo

Re: Boolean Expressions

2017-09-26 Thread Cai Gengyang
I'm trying to understand the logic behind AND. I looked up Python logic tables False and False gives False False and True gives False True and False gives False True and True gives True. So does that mean that the way 'and' works in Python is that both terms must be True (1) for the entire expr

Re: Boolean Expressions

2017-09-26 Thread sohcahtoa82
On Tuesday, September 26, 2017 at 2:54:32 PM UTC-7, Chris Angelico wrote: > On Wed, Sep 27, 2017 at 7:43 AM, Cai Gengyang wrote: > > Help check if my logic is correct in all 5 expressions > > > > > > A) Set bool_one equal to the result of > > False and False > > > > Entire Expression : False and F

Re: Boolean Expressions

2017-09-26 Thread Chris Angelico
On Wed, Sep 27, 2017 at 7:43 AM, Cai Gengyang wrote: > Help check if my logic is correct in all 5 expressions > > > A) Set bool_one equal to the result of > False and False > > Entire Expression : False and False gives True because both are False This is not correct, and comes from a confusion in

Boolean Expressions

2017-09-26 Thread Cai Gengyang
Help check if my logic is correct in all 5 expressions A) Set bool_one equal to the result of False and False Entire Expression : False and False gives True because both are False B) Set bool_two equal to the result of -(-(-(-2))) == -2 and 4 >= 16 ** 0.5 -(-(-(-2))) is equal to 2, and 2 i

Re: Understanding Boolean Expressions

2013-04-17 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Wed, 17 Apr 2013 11:47:49 +0300, Jussi Piitulainen wrote: > > > Steven D'Aprano writes: > > > >> So paradoxically, that means that "x or y" counts as an and_test > >> (obviously!) but also as an or_test, since every and_test also counts > >> as an or_test. Here's so

Re: Understanding Boolean Expressions

2013-04-17 Thread Steven D'Aprano
On Wed, 17 Apr 2013 11:47:49 +0300, Jussi Piitulainen wrote: > Steven D'Aprano writes: > >> So paradoxically, that means that "x or y" counts as an and_test >> (obviously!) but also as an or_test, since every and_test also counts >> as an or_test. Here's some crappy ASCII art of a Venn diagram >

Re: Understanding Boolean Expressions

2013-04-17 Thread Jussi Piitulainen
Steven D'Aprano writes: > So paradoxically, that means that "x or y" counts as an and_test > (obviously!) but also as an or_test, since every and_test also > counts as an or_test. Here's some crappy ASCII art of a Venn diagram I think you mean to say that "x and y" counts as an and_test and also

Re: Understanding Boolean Expressions

2013-04-17 Thread Steven D'Aprano
On Tue, 16 Apr 2013 15:19:25 -0700, Bruce McGoveran wrote: > Hello. I am new to this group. I've done a search for the topic about > which I'm posting, and while I have found some threads that are > relevant, I haven't found anything exactly on point that I can > understand. So, I'm taking the

Re: Understanding Boolean Expressions

2013-04-16 Thread Bruce McGoveran
Thank you all for thoughts. I'm just about to post another question about atoms and primaries. If you have a moment to look it over, I would appreciate your thoughts. Many thanks in advance. On Tuesday, April 16, 2013 6:19:25 PM UTC-4, Bruce McGoveran wrote: > Hello. I am new to this group.

Re: Understanding Boolean Expressions

2013-04-16 Thread Terry Jan Reedy
[2nd try, quotation a bit messed up] On 4/16/2013 6:19 PM, Bruce McGoveran wrote: > Hello. I am new to this group. I've done a search for the topic > about which I'm posting, and while I have found some threads that are > relevant, I haven't found anything exactly on point that I can > underst

Re: Understanding Boolean Expressions

2013-04-16 Thread Rhodri James
On Tue, 16 Apr 2013 23:19:25 +0100, Bruce McGoveran wrote: Hello. I am new to this group. I've done a search for the topic about which I'm posting, and while I have found some threads that are relevant, I haven't found anything exactly on point that I can understand. So, I'm taking the

Re: Understanding Boolean Expressions

2013-04-16 Thread Dave Angel
On 04/16/2013 06:19 PM, Bruce McGoveran wrote: Hello. I am new to this group. I've done a search for the topic about which I'm posting, and while I have found some threads that are relevant, I haven't found anything exactly on point that I can understand. So, I'm taking the liberty of askin

Re: Understanding Boolean Expressions

2013-04-16 Thread Walter Hurry
On Tue, 16 Apr 2013 15:19:25 -0700, Bruce McGoveran wrote: > Hello. I am new to this group. I've done a search for the topic about > which I'm posting, and while I have found some threads that are > relevant, I haven't found anything exactly on point that I can > understand. So, I'm taking the

Understanding Boolean Expressions

2013-04-16 Thread Bruce McGoveran
Hello. I am new to this group. I've done a search for the topic about which I'm posting, and while I have found some threads that are relevant, I haven't found anything exactly on point that I can understand. So, I'm taking the liberty of asking about something that may be obvious to many rea

Re: Best way to evaluate boolean expressions from strings?

2009-04-28 Thread Arnaud Delobelle
Gustavo Narea writes: > Hello, everybody. > > I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and > (bar > 2 or bar == 0)" which are defined as strings (in a database or > a plain text file, for example). How would you achieve th

Re: Best way to evaluate boolean expressions from strings?

2009-04-28 Thread Gustavo Narea
Thank you very much, Gabriela and Peter! I'm going for Pyparsing. :) -- Gustavo. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to evaluate boolean expressions from strings?

2009-04-27 Thread Peter Otten
Gustavo Narea wrote: > I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and > (bar > 2 or bar == 0)" which are defined as strings (in a database or > a plain text file, for example). How would you achieve this? > > These expressions will c

Re: Best way to evaluate boolean expressions from strings?

2009-04-27 Thread Gabriel Genellina
En Mon, 27 Apr 2009 14:03:01 -0300, Gustavo Narea escribió: I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and (bar > 2 or bar == 0)" which are defined as strings (in a database or a plain text file, for example). How would you achieve this? This

Best way to evaluate boolean expressions from strings?

2009-04-27 Thread Gustavo Narea
Hello, everybody. I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and (bar > 2 or bar == 0)" which are defined as strings (in a database or a plain text file, for example). How would you achieve this? These expressions will contain placeholders for Py