From 4a8b64349706ee706d978c46b0e640b774e124a6 Mon Sep 17 00:00:00 2001 From: Sarvesh Yadav <44526730+Sarvesh-yadav@users.noreply.github.com> Date: Mon, 20 May 2019 00:34:23 +0530 Subject: [PATCH] True and False interpretion (#32626) * True and False interpretion How true and false is interpreted by python. * Update index.md * Update index.md --- guide/english/python/boolean-operations/index.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/guide/english/python/boolean-operations/index.md b/guide/english/python/boolean-operations/index.md index 06441b4529..a44a415070 100644 --- a/guide/english/python/boolean-operations/index.md +++ b/guide/english/python/boolean-operations/index.md @@ -31,7 +31,7 @@ not x | if x is false, then True, else False | (3) False ``` ### `and`: -`` +``` >>> True and False # Second argument is evaluated. False >>> False and True # Short-circuted at first argument. @@ -47,6 +47,17 @@ not x | if x is false, then True, else False | (3) True ``` +## How python sees True and False + +For python `True==1` and `False==0` + +```python +1 and False //False +0 and 1 //False +1 and True //True +1 or 0 //True +``` + ## Other boolean-operations: These are other boolean operations which are not part of the Python language, you will have to define them yourself or use the boolean expression within the parenteses. @@ -202,3 +213,4 @@ xnor ( not (x or y) or (x and y) ) | | False >>> not(not(False or False) or (False and False)) # Second argument is evaluated. True +``` \ No newline at end of file