Premier League Predictor: FastAPI & PostgreSQL — 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 Every correct score is automatically a correct result too — if the predicted scoreline exactly matches the real one, the predicted win/draw/loss outcome necessarily matches the real outcome as well, since the outcome is derived directly from the scoreline. That relationship only runs in one direction, though: a correct result does NOT imply a correct score (a predicted 1-1 draw doesn't require the real match to also finish 1-1). So an exact-score prediction always satisfies BOTH conditions at once, while a correct-result-only prediction satisfies just the weaker one. score_prediction checks the stronger condition (exact match) first and returns immediately with POINTS_CORRECT_SCORE (40) the moment it's true. Because it returns right there, the weaker outcome check never even runs for an exact-match prediction. If the outcome check ran first instead, an exact-score prediction would still pass that check too (since its outcome does match, as explained above) — and the function would return POINTS_CORRECT_RESULT (10) and stop there, never reaching the exact-match branch at all. A user who predicted the exact real scoreline would be awarded only 10 points instead of the full 40 they actually earned — a genuine scoring bug, silently underpaying the single best possible prediction outcome in the whole system. WHY THIS WORKS AS AN ANSWER ---------------------------- It explains the real logical relationship between the two conditions (exact match implies outcome match, but not the reverse), and traces precisely what would go wrong with the ordering reversed — not a vague "it would be wrong," but the specific, concrete outcome that every exact-score prediction would be silently underpaid by 30 points.