Answers for "python and operator returns"

1

python and operator returns

'''
Now the interesting part. 
The and and or operators actually return values! 
With the and operator, each argument is evaluated, and if they all evaluate to True, 
the last argument is returned. Otherwise the first False argument is returned.
'''
a = 1
b = 5
print a and b	# 5
print b and a	# 1
print a and False	# False
print a and True	# True
print a and None	# None
print False and a	# False
print None and a	# None
print True and 'a' and 0 and True # first False item is zero, 0
Posted by: Guest on January-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language