working of boolean | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

working of boolean

https://code.sololearn.com/c8RXGEykh672/# why am i getting false for 7 th line and true for 8th line

31st Mar 2020, 11:41 AM
Mani
Mani - avatar
5 Answers
+ 3
Because the value of x is String. If you do like this int(x) == y then you will get true. so here x = "4" + "5" = "45" y = 4 * 5 = 45 ("45" == 45) = false because you are Comparing String with number. (int("45") == 45) = true
31st Mar 2020, 11:46 AM
A͢J
A͢J - avatar
+ 2
Because one is string type and another is integer type.in line eight you enter ! which means not.so in line eight code says that str is not equal to integer,thats why output is false...
31st Mar 2020, 1:35 PM
Wade
Wade - avatar
+ 1
Add this after line 5 to see that both of them belong to different class types. print(type(x)) print(type(y)) x is string. y is integer.
31st Mar 2020, 11:49 AM
Avinesh
Avinesh - avatar
0
Thanks. It was so helpful
31st Mar 2020, 11:48 AM
Mani
Mani - avatar
0
value of x is "45" which is string And y is 45 which is int string is not equal to interger
31st Mar 2020, 1:54 PM
Rishi
Rishi - avatar