The codes attached have almost the same pattern ..but why their answers are different ..amd also please explain the answers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The codes attached have almost the same pattern ..but why their answers are different ..amd also please explain the answers

https://code.sololearn.com/cJa1JS2Os8Pd/?ref=app

12th Aug 2017, 3:43 PM
Divyanshu Kulratn
Divyanshu Kulratn - avatar
2 Answers
+ 7
print(1+1 or 1*3 == 6) print(9*2 and 32 == 4*8) In both the examples you are performing logical operations on numbers and boolean variable. The logical reason behind getting 2 and true is because- Any false value OR with number will give result as number. Any true value AND with number will give result as True. I hope it helps. Let me know if you still don't get it.
12th Aug 2017, 3:51 PM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
0
@Apoorva shenoy Nayak why is it so?
12th Aug 2017, 7:51 PM
Divyanshu Kulratn
Divyanshu Kulratn - avatar