Why to put >=7 first?


#1

Just want to know why we should enter the >=7 condition before >=3 and NOT after it? I was under an impression that the interpreter would hold the latest condition as the valid one. Thanks


#2

In a pretend situation where there are return statements in each conditional branch, we would want the greater of 7 and 3 to be returned. That's one imaginary instance, at any length.

In a multiway branch we can only travel one way out of the conditional. Where doling out discounts is concerned, one should like to have the greatest that can be awarded, meaning we will test for the greater of the two first.

if days >= 7:
    # greatest discount
elif days >= 3:
    # moderate discount
else:
    # no discount

I haven't checked the lesson, or this code, but you get the meaning, right?


#3

Thanks mtf, I pretty much got what you said. However, just wondering what if the condition is such where one prefers the least to be awarded?