Add Logic (Exercise)
00:00
In this exercise, we’re adding some logic. So you should figure out what the result will be, either True
or False
, when evaluating the following expressions. So first, again, think about it and then type them into the interactive window to check your answers. And you’ve got four expressions here. First one is (1 <= 1) and (1 != 1)
.
00:20 And also keep in mind that there’s parentheses and that they can influence the order of execution, the precedence that these different subexpressions get evaluated.
00:30
And you want to know what this complete expression evaluates to, so is it going to be True
or False
in the end if all of these parts of it are evaluated. And then we have another one that is not (1 != 2)
.
00:45
And another one that reads ("good" != "bad")
and this expression is in parentheses, and then or False
. And finally, we have one that is, again, in parentheses, ("good" != "Good")
and then it continues with and not
, and again, in parentheses, we have (1 == 1)
.
01:09
This is going to require a little bit more thinking, and just go piece by piece, see what it evaluates to, is it True
or False
, and then move on to the next part, and then you will come to a final conclusion.
01:20 And let’s do this in the interactive window in the next lesson.
Become a Member to join the conversation.