Week 5 · Session 1
Asking two questions at once: and, or, not.
The ride home needs the answer code and enough battery. The lab lets you write that either way.
if inside another: the battery question is only asked once the code question heldif whose condition names both at once, joined by andand, or, nota and b is True only when both sides are Truea or b is True when at least one side is Truenot a flips True to False and back60 < temperature < 80 also works in Python: it is really two comparisons joined by andThis is Lab 2’s ride home, unchanged. Run it, then rewrite it.
if that uses and, plus one else"no" with 100, "yes" with 10, "yes" with 80else should printRun it with temperature 95. It prints "Mild," which is wrong.
or only needs one side to hold, and 95 satisfies the first half on its ownor to and so both bounds have to hold at onceor Is the One You WantNot every pair of questions is an and.
and when every condition has to hold: the code and the batteryor when any one of them is enough: did the lights at Lab 2’s tree line move, or did you hear somethingor stops at the first side that is Trueand when both questions lead to the same single outcomeelse worth telling apartSTRANDED from LEFT BEHIND: nest, or use and plus an elif. Both are right there