One-sentence summary
To finish this module, we design an algorithm that checks whether your bag is complete for the day's lessons, bringing sequence, condition, repetition, variables and input/output together in a single project.
Why does it matter?
A small project is the best way to see whether we have really learned a module. The pieces we studied one by one (ordering steps, writing a condition, building a loop) look easy on their own. Using them together is a little harder, and that is the real skill.
This project is a teaching template; we are not claiming that we built a real device. The goal is to practise turning an everyday problem into clear steps and then testing the solution. The same way of thinking will help later in Scratch, in Python and in robotics projects.
Step 1: Define the problem and requirements
Before writing any code, we need to state clearly what we are solving. A vague problem produces a vague solution.
Problem statement
Before leaving for school in the morning, we want to check that the bag is complete for today's timetable. If something is missing, the program should say which item is missing; if everything is there, it should say "ready."
Requirements
- The program takes the day's lesson list as input.
- For each lesson, it checks whether the required book is in the bag.
- It also checks everyday essentials such as the pencil case and the water bottle.
- It collects the missing items and lists them (output).
- If nothing is missing, it prints "Bag is ready."
Notice that all five pieces of the module are here. The order of steps is sequence, the "if it is missing" decision is a condition, going through each lesson is repetition, the list that holds the missing items is a variable, and the lesson list and screen messages are input/output.
Step 2: Plan the variables and the logic
List of variables
| Variable | What it holds | Example value |
|---|---|---|
lesson_list | Today's lessons | ["Maths", "Science", "PE"] |
in_bag | Items already in the bag | ["Maths book", "Pencil case"] |
needed_item | The book each lesson needs | "Science book" |
missing | Items that were not found | ["Science book"] |
ready | Is the bag complete? | True / False |
Pseudocode
Start
receive lesson_list
receive in_bag list
set missing to an empty list
Repeat for each lesson in lesson_list
needed_item = the book of the lesson
If needed_item is not in in_bag
add needed_item to the missing list
If pencil case is not in in_bag
add "Pencil case" to missing list
If water bottle is not in in_bag
add "Water bottle" to missing list
If the missing list is empty
print "Bag is ready"
Otherwise
print the missing items
End
Text-based flowchart
[Start]
|
[Receive lesson list]
|
[missing = empty list]
|
<Any lesson left to check?>
Yes | \ No
v \
<Book in the bag?> \
No | \ Yes \
v \ v
[add to (next <Is missing empty?>
missing] lesson) Yes | \ No
\ / v v
(back to loop) [Bag is ready] [Print missing]
\ /
[End]
Step 3: Write it in Python and test it
When we translate the pseudocode into a real language, we can see whether the logic works.
def check_bag(lesson_books, in_bag):
missing = []
for lesson in lesson_books:
book = lesson_books[lesson]
if book not in in_bag:
missing.append(book)
for item in ["Pencil case", "Water bottle"]:
if item not in in_bag:
missing.append(item)
if len(missing) == 0:
return "Bag is ready"
return "Missing: " + ", ".join(missing)
Three test scenarios
| # | Input | Expected output |
|---|---|---|
| 1 | All books present, pencil case and water bottle present | Bag is ready |
| 2 | Science book absent, rest present | Missing: Science book |
| 3 | Maths book and water bottle absent | Missing: Maths book, Water bottle |
Running the scenarios by hand and comparing them with the expected output is the most honest way to show that the algorithm actually works.
Mini practice
Write out your own bag in a table. Run the check_bag function above on paper or on a computer. Then add a fourth test scenario: for example, what happens if yesterday's book is in the bag by mistake? Does the program notice this as an "extra item," or does it ignore it? Write your answer in one sentence.
Project strengthening plan
A working demonstration is not enough for Algorithm Mini Project: Smart Bag Check. A strong project also makes its aim, user, limits, test conditions and failed attempts visible. Use the context of a route that guides a robot safely to a classroom target to produce a clear algorithm, pseudocode and a test table. Although the lesson aims to “Use the whole module to design, pseudocode, test and debug a smart bag-check algorithm”, do not present an unmeasured result as a confirmed success.
1. Project summary and scope
Write three sentences: What problem are you solving, who is affected by it, and what will the first version deliberately not do? Stating what is outside the scope does not weaken a project; it makes the project finishable. Describe the connection between Step 1: Define the problem and requirements and Requirements as the main assumption, then name the test that can confirm or reject it.
2. Acceptance criteria
- Are the steps clear and unambiguous?
- Are the start and finish conditions defined?
- Were normal, boundary and invalid cases tested?
- Is there an unnecessary step or repetition?
- Can another person follow the algorithm and obtain the same result?
Do not leave an acceptance criterion for “Algorithm Mini Project: Smart Bag Check” as a vague statement such as “it works”. Choose an observable measure such as time, distance, correct trials, screen width or user steps. When direct measurement is difficult, record whether the same behaviour appears in three consecutive trials.
3. Test matrix
| Test | Condition | Expected | Actual result | Next decision |
|---|---|---|---|---|
| Normal | Standard input and complete setup | The core task is completed | Fill in during the test | Keep it or make a small improvement |
| Boundary | Lowest or highest accepted value | The system remains stable | Fill in during the test | Review the threshold or rule |
| Error | Missing, wrong or unexpected input | A safe and clear response | Fill in during the test | Add error handling |
| Repeat | At least three trials under the same condition | Similar results | Fill in during the test | Investigate the source of inconsistency |
4. Version log
For every version of “Algorithm Mini Project: Smart Bag Check”, record the date, the one main decision changed, the reason and the test result. A first version that fails is evidence about which assumption involving Step 1: Define the problem and requirements or Requirements should be reconsidered. Remove personal information and private background details from images.
5. Presentation and self-review
Prepare a two-minute explanation of “Algorithm Mini Project: Smart Bag Check”: the problem, the solution approach, the most important result for a route that guides a robot safely to a classroom target, and the next step. Instead of saying the project is complete, state which part has been verified and which part still needs development.
Common mistakes
Finding the bug
A student wrote the function but got "Missing" even in scenario 1. Checking the code, they found this line:
if book in in_bag: # wrong
missing.append(book)
The condition is reversed: it counts a book as missing when it is in the bag. The fix is to use not in:
if book not in in_bag: # correct
missing.append(book)
Other common mistakes
- Forgetting to empty the missing list before the loop carries yesterday's missing items into today.
- Case differences: "science book" and "Science book" look different to the computer.
- Writing separate code for every lesson; a loop does that repetition for us.
Safety note
This lesson is a thinking project that runs entirely on paper and screen. If you later want to turn it into a real prototype (for example a light warning or a box with a sensor), any step involving batteries, motors, cutting tools or hot surfaces should be done under adult supervision. Never work with mains electricity.
Lesson summary
- A module-finishing project lets us combine the pieces we learned into a single problem.
- The bag check uses sequence, condition, repetition, variables and input/output all at once.
- A good solution starts with a clear problem statement and requirements.
- Pseudocode and a flowchart let us see the logic before writing code.
- Comparing test scenarios with the expected output catches mistakes early.
Check questions
- What job does the loop do in this project?
- What is the
missingvariable for, and why is it emptied before the loop? - Why is
not inneeded in the condition instead ofin? - What is the expected output of test scenario 3?
- If you turn this project into a real device, which safety rule would you follow?
Answers
- It goes through each lesson in the list one by one and checks whether that lesson's book is in the bag, so we do not have to write the same check by hand over and over.
- It collects the items that were not found. It is emptied before the loop so that missing items from a previous check do not mix into the new result.
- We want to count an item that is not in the bag as missing.
not inmeans "if it is not in the list"; usinginreverses the logic. Missing: Maths book, Water bottle- Doing any step with batteries, motors, cutting tools or hot surfaces under adult supervision, and staying away from mains electricity.
Source and verification note
For “Algorithm Mini Project: Smart Bag Check”, verification focuses on whether the relationship between Step 1: Define the problem and requirements and Requirements remains consistent across examples. The algorithms in this lesson are checked by tracing sample inputs by hand and comparing them with expected outputs. Pseudocode is used to make the reasoning sequence visible without tying it to one programming language.
Next lesson
Programming with Scratch module and the Robotics & Coding Starter Quiz: We move algorithmic thinking into a real program built from blocks, and test what we have learned with a short quiz.