Peer Instruction: Booleans Multiple Choice QuestionsΒΆ
- Only (7>2)
- Correct! Python evaluates from left to right. If the first part of an expression containing 'or' is True, the truth of the statement is know.
- Only (9<2)
- Incorrect! Python evaluates from left to right.
- Only (8>3)
- Incorrect! Python evaluates from left to right.
- (7>2) and (8>3)
- Incorrect! Python evaluates from left to right.
- All the code is evaluated
- Incorrect! The (7 > 2) is joined by an or so since (7 > 2) is true, evaluation stops.
Q-1: In the following expression, which parts are evaluated?
(7 > 2) or ( (9 < 2) and (8 > 3) )
- Only (7>2)
- Incorrect! Python evaluates from left to right and must evaluate both sides of an expression when they are joined by "and".
- Only (9<2)
- Incorrect! Python evaluates from left to right and must evaluate both sides of an expression when they are joined by "and".
- Only (8>3)
- Incorrect! Python evaluates from left to right and must evaluate both sides of an expression when they are joined by "and".
- (7>2) and (8>3)
- Incorrect! Python evaluates from left to right. The ((7 > 2) and (9 < 2)) will be evaluated first.
- All the code is evaluated
- Correct! The truth of this expression is not established until all parts have been evaluated.
Q-2: In the following expression, which parts are evaluated?
( (7 > 2) and (9 < 2) ) or (8 > 3)
You have attempted of activities on this page