python and operator returns

Solutions on MaxInterview for python and operator returns by the best coders in the world

showing results for - "python and operator returns"
Clay
25 Nov 2018
1'''
2Now the interesting part. 
3The and and or operators actually return values! 
4With the and operator, each argument is evaluated, and if they all evaluate to True, 
5the last argument is returned. Otherwise the first False argument is returned.
6'''
7a = 1
8b = 5
9print a and b	# 5
10print b and a	# 1
11print a and False	# False
12print a and True	# True
13print a and None	# None
14print False and a	# False
15print None and a	# None
16print True and 'a' and 0 and True # first False item is zero, 0