──────────────────────────────────────

28. The Scoreboard Workshop · Build a Tournament Points Calculator

Implement a reusable scoring rule and test it on several records.

Lesson files · lessons/functions/points-calculator

Before you start
- Pass numbers to a function and return a calculated result.
- Keep input and printing in the code that calls the function.

By the end
- Use a function to combine wins and draws under one scoring rule.
- Test the rule with a mixed result, only draws and zero games.

Where you can use it
Work out totals for several teams in a tournament. Send each team’s wins and draws to the same function so the rule stays consistent.

Each win earns three points and each draw earns one. Calculate expected results by hand before editing the function. Two wins and one draw are worth 7. Three draws and no wins are worth 3. Zero games are worth 0.

The starter adds wins and draws, which gives 3 for the first case. Put the scoring rule inside points_for and keep the caller's input and print steps. Run all three cases after your edit.

Predict
How many points should three draws give?
- 9
- 3

Worked example (example.py)

def points_for(wins, draws):
    return wins + draws

wins = int(input())
draws = int(input())
print(f"Points: {points_for(wins, draws)}")


Example input
2
1

Example result
Points: 3

Correct points_for(wins, draws) to return three points per win and one per draw. Read wins and draws on separate lines and print Points: and the total.

Starter program (starter.py)

def points_for(wins, draws):
    return wins + draws

wins = int(input())
draws = int(input())
print(f"Points: {points_for(wins, draws)}")


Starter input
2
1

Hint
Use wins * 3 to count the points from wins. How many points should the draws add?

Case 1. Try the sample
Input
2
1
Expected output
Points: 7

Case 2. All draws
Input
0
3
Expected output
Points: 3

Case 3. Zero games
Input
0
0
Expected output
Points: 0

Project checklist
Run the sample case.

Project checklist
Try one different case and explain what happened.

Marking criterion
Program behaviour (4 points)
Each required behaviour works on the supplied cases.

Marking criterion
Use of the lesson concept (3 points)
The code uses the main idea in a clear, purposeful way.

Marking criterion
Test evidence (2 points)
The reflection describes a case, its expected result and what happened.

Marking criterion
Explanation (1 points)
The learner explains a change or design decision in their own words.

Stretch
Use points_for for two teams and report which has the higher total.

Reflect
Why does the function accept wins and draws separately?

Check your prediction
3 Each draw is worth one, while each win is worth three.
