0%

Making Decisions · capstone

Capstone project: Project: Build a Recommendation Tool

You can now make a program choose among several paths using comparisons, , and user answers. This project combines those skills in an interactive recommendation tool.

You choose the tool’s subject and recommendation text. It could suggest activities, books to read, ways to practice a hobby, meal ideas, study approaches, or another suitable topic.

The program’s structure stays consistent so you can test it and receive useful automated feedback.

Personalize five strings

Create non-empty for these :

VariablePurpose
tool_titleA title printed at the top of the report
quick_choiceA recommendation for anyone with less than 20 minutes
active_choiceA recommendation for an active preference with at least 45 minutes
quiet_choiceA recommendation for a quiet preference with 20 minutes or more
flexible_choiceA fallback for another preference with 20 minutes or more

Make all four recommendation strings different. The values can match any subject you choose.

For an activity guide, you might use short values such as "Take a brisk walk" or "Read a chapter". Those are examples, not required answers.

Collect two answers

Ask for a preference and a number of available minutes. Clean the preference and convert the number. These input calls are already in the project’s Editor. While building the collect-and-clean checkpoint, add the two temporary print calls below, press Run, and answer each question in the with Enter:

preference = input("Preference (active or quiet): ").strip().lower()
minutes = int(input("Minutes available: "))

print(f"Cleaned preference: {preference}")
print(f"Minutes as a number: {minutes}")

Try ACTIVE with spaces at both ends and 60 minutes. The temporary checks should show active and 60. Remove these two print calls when you add the final four-line report.

The project assumes the minutes answer is a whole number. You do not need to add try/except or a validation .

Apply the rules in order

Choose recommendation with one /elif/else chain. Use these rules in this exact order:

  1. When minutes is less than 20, choose quick_choice regardless of preference.

  2. Otherwise, when preference is "active" and minutes is at least 45, choose active_choice.

  3. Otherwise, when preference is "quiet", choose quiet_choice.

  4. In every other case, choose flexible_choice.

The order is part of the design. The quick rule comes first because it overrides the preference when little time is available.

Print a four-line report

After the decision, print this structure with the actual values:

[tool title]
Preference: [cleaned preference]
Minutes: [number]
Recommendation: [chosen recommendation]

Do not print the square brackets. They show where your values belong.

Build in checkpoints

1. Personalize

Write the title and four different recommendation strings. Print them temporarily if you want to check spelling.

2. Collect and clean

Add the two input calls. Run the program with extra spaces and uppercase letters in the preference to confirm that the stored is cleaned.

3. Choose

Build the branches in the required order. one of your four choice variables to recommendation in every branch.

4. Present

Print the four-line report. Remove temporary checks that are not part of the report.

Test every path

Run at least these four cases before submitting:

PreferenceMinutesExpected choice variable
active10quick_choice
active60active_choice
quiet30quiet_choice
another word30flexible_choice

Also test the boundary values 20 and 45. Saying each rule aloud before running it can help you predict the result.

Before you submit

Check that:

  • the title and all four choices are non-empty strings;

  • the four recommendation strings are different;

  • preference is stripped and lowercased;

  • minutes is converted with int();

  • the quick branch comes first;

  • the active branch uses and and includes the 45 boundary;

  • every branch assigns one of your personalized choice variables;

  • the report contains exactly the four required non-empty lines after the input prompts.

If your plan includes Guided, you can ask Monty:

Review my recommendation tool one rule at a time. Check the order and boundary values without rewriting the program for me.

After it passes

Try different recommendation text while keeping the decision rules intact. Then trace one of the four test cases by hand and follow how Python skips until it reaches the first true branch.

You have moved from programs that always follow one path to programs that respond to their current data. The next chapter introduces , which let one program work with an ordered collection of related values.

Task

Build and personalize an interactive recommendation tool.

  1. Write a non-empty tool_title and four different recommendation .

  2. Clean preference with .strip().lower() and convert minutes with int().

  3. Choose quick_choice below 20 minutes.

  4. Choose active_choice for an active preference with at least 45 minutes.

  5. Choose quiet_choice for a quiet preference when the quick rule did not match.

  6. Use flexible_choice in every other case.

  7. Print the required four-line report.

Submit uses private input with spaces and uppercase letters. Enter a whole number when testing the program yourself.