Please tell why the output is False????? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
21st Apr 2020, 6:29 PM
ANJALI SAHU
7 Answers
+ 6
True!=0==True ... is evaluated like this: True!=0 and 0==True Since 0 doesn't equal True, you get False.
21st Apr 2020, 6:45 PM
HonFu
HonFu - avatar
+ 6
I don't know about python but hope this may help you, python visualizer. http://www.pythontutor.com/visualize.html#mode=edit
22nd Apr 2020, 5:00 AM
Puthur Harthik
+ 5
Thanks HonFu ☺️☺️☺️
21st Apr 2020, 6:48 PM
ANJALI SAHU
+ 4
I evaluated it as (True!=0)==True
21st Apr 2020, 6:49 PM
ANJALI SAHU
+ 4
Yeah, that's how many other languages would do it. Python goes its own way in that respect, so you can for example write stuff like: if 3<x<10: Which means that x is between 4 and 9.
21st Apr 2020, 8:33 PM
HonFu
HonFu - avatar
+ 2
print(True!=0==True) Dear, two statements are there 1--- True!=0 (Which Is true) 2--- 0==True (Which is False) Now Results here True==False (Result will be False) run... False I think now you can understand better
22nd Apr 2020, 6:50 AM
Rana Kamran Suleman
Rana Kamran Suleman - avatar
0
Python is a multithreaded language and in this particular case it is comparing 0 from both LHS and RHS simultaneously giving true from LHS and false from RHS which now we have True and False which gives False..
23rd Apr 2020, 5:18 PM
Ashish Kumar
Ashish Kumar - avatar