What you'll build
A small provision shop wants a program to handle a sale. 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.
- Read the shop scenario under The scenario below — twice. Picture the moment at the counter before you write anything down.
- Find the separate jobs hiding in the story. Some are calculations, some are decisions, and one or two simply show something to the customer. Each separate job is a candidate for its own function — aim for at least four, and keep each one to a single job.
- 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?
- 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 to the customer, it may not need to return anything; if the program will use the result later, it should return it.
- Add a fifth function of your own — maybe one that checks whether an item is in stock, or one that greets the customer by name.
- For one of your functions, explain in a sentence *why* you chose to return a value, or why you chose not to.
The scenario
Akua runs a small provision shop. A customer comes to the counter with a few things — two tins of milk, a bag of rice, a bar of soap. Akua has to tell them what they owe, take off the 10% she is running on soap this week, collect the cash the customer hands over, give back the right change, and tear off a small receipt. Today all of that lives in one long stretch of code, so when something looks wrong — say the change comes out short — she has to reread the whole thing to find the mistake. 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 shop — it is only there to show you what a finished answer looks like.
Name: verdict
Information it needs: a single exam score
Job: decides whether that score is a pass or a fail
Returns an answer? Yes — it returns the word "Pass" or "Fail",
so the rest of the program can act on itHow we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| Four functions | At least four functions, each doing a single, clear job rather than one function trying to do everything. | 1 |
| Right shape | Each function has a sensible verb-style name and lists the information (inputs) it would need. | 1 |
| Job is clear | Each function's job is described in plain words a non-programmer could follow. | 1 |
| Return decision | For each function you say whether it returns an answer, and the choice makes sense — print-only versus handing a value back. | 1 |