Premier League Predictor: Django & MySQL — Chapter 6, Exercise 1 ==================================================== TASK Explain why score_prediction checks for an exact scoreline match before checking the outcome, and what would go wrong (in terms of points actually awarded) if the outcome check ran first instead. SOLUTION The two conditions score_prediction checks aren't independent — an exact scoreline match logically implies an outcome match too, because the outcome (home win / away win / draw) is computed directly from the scoreline. If predicted_home == actual_home and predicted_away == actual_away, then _outcome(predicted_home, predicted_away) is necessarily equal to _outcome(actual_home, actual_away), since they're literally the same two numbers being compared the same way. The relationship only holds in one direction, though: a correct outcome does NOT imply a correct scoreline (a predicted 1-1 draw doesn't require the real match to also finish 1-1, only that both are draws). score_prediction checks the stronger condition — the exact score match — first, and returns POINTS_CORRECT_SCORE (40) immediately if it's true. Because of that early return, the weaker outcome check never even executes for a prediction that got the exact score right. If the order were reversed and the outcome check ran first, an exact-score prediction would still pass it (since, as shown above, its outcome necessarily matches too) — and the function would return POINTS_CORRECT_RESULT (10) and stop there, before the exact-match branch was ever reached. Every user who predicted the exact real scoreline would be silently awarded only 10 points instead of the 40 they actually earned. It wouldn't raise an error or look obviously broken — the prediction would just be quietly, incorrectly underpaid by 30 points every single time, which is exactly why the order in which these two checks run matters as much as the checks themselves. WHY THIS WORKS AS AN ANSWER ---------------------------- It identifies the real logical relationship between the two conditions (exact match implies outcome match, never the reverse), and traces the specific, concrete consequence of reversing the check order — not a vague "it would be wrong," but the exact silent underpayment (40 points reduced to 10) that every correctly predicted exact score would suffer.