I am trying some operations in Python but I am not understanding the underlying concept of it. I tried various combinations which might be bit tough for you but my objective was how it is working internally in Python.Please find the code below:
>>> 2 or 3
2
>>> 3 or 2
3
>>> 3 or 3
3
>>> 3 or -3
3
>>> -3 or 3
-3
>>> 0 or 3
3
>>> 0 or -9
-9
>>> 3 and 4
4
>>> 3 and 6
6
>>> 0 or None
>>> 0 and None
0
>>> None and 0
>>> None or 0
0
>>> 5 and 2
2
>>> -3 and 6
6
>>> 3 and -6
-6
>>> 3 and 0
0
>>> 0 and 0
0
>>> 0 and 0.0
0
>>> 0.0 and 0
0.0
>>> 0.0 or 0
0
>>> 0 or 0.0
0.0
>>> [] or 3
3
>>> 3 or []
3
>>> 0 or []
[]
>>> [] or 0
0
>>> [] and 3
[]
>>> 3 and []
[]
>>> [] or {}
{}
>>> [] and {}
[]
>>> [] and {}
[]
>>> {} or []
[]
>>> {} and []
{}