This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong Output
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Kshitish, steven.daprano
Priority: normal Keywords:

Created on 2020-11-25 09:41 by Kshitish, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
PROOF.jpg Kshitish, 2020-11-25 09:41 Please check the image for better understanding
Logic.jpg Kshitish, 2020-11-25 09:42
Messages (2)
msg381806 - (view) Author: Nishant Gautam (Kshitish) * Date: 2020-11-25 09:41
The python give wrong output
msg381809 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-11-25 09:56
Correct output.

https://docs.python.org/3/reference/expressions.html#operator-precedence

a = 10
b = 10
(a >= 10) and not (b == 10) | 7+2 == 9

returns False because of operator precedence. It evaluates like this:

(a >= 10) and not (b == 10) | 7+2 == 9
--> True and not True | 7+2 == 9
--> True and not True | 9 == 9
--> True and not 9 == 9
--> True and not True
--> True and False
--> False
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86626
2020-11-25 09:56:51steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg381809

resolution: not a bug
stage: resolved
2020-11-25 09:42:45Kshitishsetfiles: + Logic.jpg
2020-11-25 09:41:43Kshitishcreate