Python's Logical Operator AND -
i'm little confused results i'm getting logical operators in python. i'm beginner , studying use of few books, don't explain in detail i'd like.
here own code:
five = 5 2 = 2 print 5 , 2 >> 2
it seems outputting 2 variable.
five = 5 2 = 2 0 = 0 print 5 , 2 , 0
so, added variable integer. printed , got following output:
>> 0
what going on python in background? why isn't output 7 or 5, 2.
python boolean operators return last value evaluated, not true/false. docs have explanation of this:
the expression
x , y
first evaluatesx
; ifx
false
, value returned; otherwise,y
evaluated , resulting value returned.
Comments
Post a Comment