AssignmentsWeek 02 · Decisions and structurePlan the school results program
wk02.p15Practice exerciseWeek 02 · Decisions and structureOpen · due next week

Plan the school results program

A school wants a program to handle a student's results. You won't write any code — you'll plan the functions the program needs, describing each one in plain words: its name, what it needs, its job, and whether it hands back an answer.

What you'll build

A school wants a program to handle a student's results. You won't write any code — you'll plan the functions the program needs, describing each one in plain words: its name, what it needs, its job, and whether it hands back an answer.

Requirements

The must-do parts. If any are missing, we'll ask you to take another pass.

  1. Read the school scenario under The scenario below — twice. Picture a real student's row of marks before you write anything down.
  2. Find the separate jobs hiding in the story. Some are calculations, some are decisions, and one or two simply show something on screen. Each separate job is a candidate for its own function — aim for at least four, and keep each one to a single job.
  3. For each function you find, answer the four questions: (1) What is its name? (2) What information does it need? (3) What job does it do? (4) Does it return an answer — and if so, what?
  4. Write in plain words — no Python needed. A good function name is a verb (see the worked example below for the shape of an answer). Rule of thumb for question 4: if the function only shows something on screen, it may not need to return anything; if the program will use the result later, it should return it.
Bonus, if you're feeling brave
  • Add a fifth function of your own — maybe one that finds the highest score, or one that checks whether the student passed every subject.
  • For one of your functions, explain in a sentence *why* you chose to return a value, or why you chose not to.

The scenario

Mr. Owusu teaches a class and keeps each student's scores in a few subjects — say maths, English, and science. At the end of term he sits with one student's row of marks and has to work out how they did: their total across the subjects, how that averages out, whether it lands a distinction, a pass, or a fail, and a tidy report card to hand to the parent. Today he would write all of that as one long block of code, so when a number looks off — say the average seems too high — he has to reread the whole thing to find where it went wrong. Your job is to plan how to break this work into small, named pieces, so each part can be written and checked on its own. The worked example below is from last week's lesson, not the school — it is only there to show you what a finished answer looks like.

A worked example — from last week, not the school
Name:           greet
Information it needs:  a person's name
Job:            builds a short welcome line for that person
Returns an answer?     Yes — it returns the greeting text, like
                "Welcome, Ama!", so the program can print or reuse it

How we'll grade it

Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.

CheckWhat we look forPt
Four functionsAt least four functions, each doing a single, clear job rather than one function trying to do everything.1
Right shapeEach function has a sensible verb-style name and lists the information (inputs) it would need.1
Job is clearEach function's job is described in plain words a non-programmer could follow.1
Return decisionFor each function you say whether it returns an answer, and the choice makes sense — print-only versus handing a value back.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →