0

Comparing numbers with boolean true false

in the code print( 1 == 1 < 2) why is the result coming out to be true & not an error. If according to precedence == operator is performed first then print(true<2) should give an error.

19th Sep 2017, 2:42 PM
Tarandeep Singh Kalra
Tarandeep Singh Kalra - avatar
2 ответов
+ 1
no here 1==1 will return 1 which is mainly value for true and after that 1<2 will true
19th Sep 2017, 2:47 PM
kanishk goel
kanishk goel - avatar
0
@@Tarandeep singh in python....by default 0=False and 1=True print(True==1)....outputs True print(True==0)....outputs False print(True==(any other number))....outputs False print(1==1<2) --> print(True<2) --> print(1<2)......outputs True
19th Sep 2017, 3:27 PM
sayan chandra
sayan chandra - avatar