-2

Output of this code is 2. Can anyone explain how ?

   > a = True
   > b = 0
   > c = 2
   > print((a OR b ) AND c)
Adi
  • 21
  • 3
  • 6
    did you read the documentation ? What was unclear? – Ma0 Jun 11 '18 at 08:51
  • 5
    Possible duplicate of [Strange use of python's and / or operator](https://stackoverflow.com/questions/47007680/strange-use-of-pythons-and-or-operator) – Mike Scotty Jun 11 '18 at 08:54

1 Answers1

1

Logical AND (and):

Return the first Falsey value if there are any, else return the last value in the expression.

Logical OR (or):

Return the first Truthy value if there are any, else return the last value in the expression.

Soorya J
  • 23
  • 12