Operator Precedence/Boolean Logic
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Jun 22 02:02:55 EDT 2016
More information about the Python-list mailing list
Wed Jun 22 02:02:55 EDT 2016
- Previous message (by thread): Operator Precedence/Boolean Logic
- Next message (by thread): Operator Precedence/Boolean Logic
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wednesday 22 June 2016 13:40, Elizabeth Weiss wrote: > Hi There, > > I am a little confused as to how this is False: > > False==(False or True) > > I would think it is True because False==False is true. Remember that parentheses are always evaluated first. So Python evaluates: False or True first, which evaluates as True. Then it evaluates False == True, which is obviously False. Why is "False or True" True? Well, consider this question: Who is allowed on the rides at the amusement park? - people over 18, regardless of their height; - people under 18, if they are "this tall" (4ft 6in) or greater. Is Fred (16 years old, and 5ft 6in tall) allowed on the ride? Only if: - he is over 18, or taller than "this tall"; - which is "False or True" - which is True Does that help? -- Steve
- Previous message (by thread): Operator Precedence/Boolean Logic
- Next message (by thread): Operator Precedence/Boolean Logic
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list