+ 2
Why is >>>True or False >>> True? And why is >>>5 or 7 >>>5
4 Respostas
+ 4
FOR THE FIRST STATEMENT:
or operator evaluates to True if either (or both) of its arguments are True, and False if both arguments are False.
FOR THE SECOND STATEMENT (5or7)
If you’re testing two objects using or , then the operator will return the first object that evaluates to true .
For e.g.:
Input:6 or 8
output: 6
Input:0 or 8
output: 8
Input:9 or 0
output: 9
I HOPE IT HELPS!🙂
+ 6
The first part:
Why is True or False>>>True
The code looks at the options, the first option is true, so return >>>True
Once it has a true result, it stops looking for another result.
So 5 or 7?
What is the first True result?
5
+ 2
Thanks to both of you! 👍 I just found out that most values evaluate to True except 0 and empty strings, arrays. Now it all makes sense