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

69. Make Your Own Python Tool · Turn a Problem Into a Brief

Choose a user and define rules you can test with specific inputs.

Lesson files · lessons/make-your-own-tool/choose-a-problem

Before you start
- Read rules in a short project brief and predict outputs from sample input.
- Compare numbers using a condition and test equality at the cutoff.

By the end
- Turn a user’s decision into a brief with defined input, output and expected cases.
- Apply the sample stock rule below and exactly at the minimum.

Where you can use it
Ask a seed exchange volunteer how they decide when to restock, then write a testable rule for the quantity that should trigger an alert.

A good brief starts with a person who repeats a task. A seed exchange volunteer might count packets by crop to decide what to restock. Write what they give your tool, what it reports and how they will use the result.

Make the first rule small enough to check on paper. If the club needs at least three packets, write down what the report should say for two packets and for exactly three before you run the code.

Predict
What should stock_status(3, 3) return?
- OK.
- Low.

Worked example (example.py)

def stock_status(quantity, minimum):
    if quantity < minimum:
        return "Low"
    return "OK"

print(stock_status(2, 3))


Example result
Low

Use one line of input in the form label|quantity|minimum, such as Beans|2|3. Print the label and Low or OK as Beans: Low. A quantity equal to the minimum is OK.

In your notes, write a brief for a person who could use this check. Describe their decision and give one sample below the minimum and one exactly at it, with the expected output for each.

Starter program (starter.py)

label, quantity, minimum = input().split("|")
print(label)


Starter input
Beans|2|3

Hint
The starter splits the line for you. Convert the two number strings with int() before comparing them.

Case 1. Try the sample
Input
Beans|2|3
Expected output
Beans: Low

Case 2. Exactly on target
Input
Comics|3|3
Expected output
Comics: OK

Case 3. Small numbers and a numeric comparison
Input
Lanterns|2|10
Expected output
Lanterns: Low

Stretch
Ask your user what they would do if a quantity were missing. Add one case to your brief showing the message that would help them recover.

Reflect
What information would you ask your user for before writing the first line?

Check your prediction
OK. A quantity equal to the minimum meets the target.
