One-sentence summary
We will write a small Python program that, when you enter a day, lists that day's lessons and the books you need, then tells you which books are missing from your bag.
Why does this matter?
In the Algorithms module we talked about the "smart bag" idea: we wrote clear steps for checking your bag in the morning. Back then it was only pseudocode. Now we will turn the same idea into a real, working program.
This project brings together three tools we have learned: storing information in a dictionary and a list, taking input from the user, and building conditions and loops. So a single small program combines the most important parts of the module.
While writing this program I ran into a small bug, and below I share how I fixed it too. The code did not work on the first try; the important part was finding where the mistake was.
How do we store a timetable?
When a program needs to hold a lot of related information, we use a dictionary. A dictionary matches each piece of information to a key. In a real dictionary you find a word and read its meaning; in a Python dictionary you give the key and get back its value.
Matching days to lessons
Let's write each day's lessons next to it as a list. A list holds several ordered values inside square brackets.
timetable = {
"monday": ["maths", "english", "science"],
"tuesday": ["history", "maths", "music"],
"wednesday": ["science", "geography", "english"],
}
Here the key is a day name and the value is that day's lessons. If we write timetable["tuesday"], Python gives us the list ["history", "maths", "music"]. The nice thing about a dictionary is that we find information by its meaning, not by its position. We reach the answer to "which lessons are on Tuesday?" straight from the day name, without memorising where the list sits.
Matching each lesson to a book
In a second dictionary, let's store which book each lesson needs.
books = {
"maths": "Maths book",
"english": "English book",
"science": "Science book",
"history": "History book",
"music": "Music book",
"geography": "Geography book",
}
Now books["science"] gives us the value "Science book". By combining the two dictionaries, we can go from a day's lessons to the list of books we need.
Taking a day from the user and showing the lessons
Let's move to the part where the program talks to the user. We will take a day, look it up in the dictionary, and print the lessons one by one.
Making the input safe
The user might type "Monday", "monday", or " monday" with spaces. To treat them all the same, we make the input lowercase and remove the spaces at the edges.
day = input("Which day shall we check? ").lower().strip()
lower() turns every letter lowercase, and strip() removes the spaces at the edges. That way we get the same result no matter how the user typed it.
Printing the lessons with a loop
Now we will move through that day's lessons. Because we repeat the same work for each lesson, we use a for loop. In Python the lines inside a loop are written with 4 spaces of indentation; the indentation shows that those lines belong to the loop.
if day in timetable:
lessons = timetable[day]
print(day.capitalize(), "lessons:")
for lesson in lessons:
print("-", lesson, "->", books[lesson])
else:
print("No timetable found for this day.")
The line if day in timetable checks whether the entered day is in the dictionary. If it is, we list the lessons; if not, we give a polite warning. The in keyword makes this check very easy.
Checking for missing books
This was the real goal of the project: which of today's required books are not in the bag? For this, let's keep the books already in the bag in a list, then look up each required book in that list.
books_in_bag = ["Maths book", "Science book"]
anything_missing = False
for lesson in lessons:
needed = books[lesson]
if needed not in books_in_bag:
print("MISSING:", needed)
anything_missing = True
if not anything_missing:
print("Great! All your books are in the bag.")
The expression not in asks "is this value not in the list?" We keep a flag variable called anything_missing: if the loop finds nothing missing, its value stays False and at the end we print a nice message.
Putting the whole program together
When we gather the two dictionaries, the input, the loop, and the missing check into one file, the program is complete.
day = input("Which day shall we check? ").lower().strip()
if day in timetable:
lessons = timetable[day]
print(day.capitalize(), "lessons:")
for lesson in lessons:
print("-", lesson, "->", books[lesson])
for lesson in lessons:
if books[lesson] not in books_in_bag:
print("MISSING:", books[lesson])
else:
print("No timetable found for this day.")
Testing the program
If the user enters monday, we see this on the screen:
Monday lessons:
- maths -> Maths book
- english -> English book
- science -> Science book
MISSING: English book
Because the Maths and Science books are in the bag, only the English book shows up as missing. The program works exactly as we wanted. Trying different days is a good habit: if you enter wednesday, the lessons and missing books change, and if you enter an undefined day like saturday, you see the "not found" message. Every new input lets us test a different path through the code.
Mini practice
Three tasks to make the program your own:
- Add the lessons for
thursdayandfridayto thetimetabledictionary. For any new lessons, also add a book to thebooksdictionary. - At the end, print how many books are missing in total. Hint: keep a
count = 0variable and docount = count + 1for each missing book. - If the user enters a day that is not in the dictionary, print which days are defined. Hint: you can loop through the keys with
for day in timetable:.
Project strengthening plan
A working demonstration is not enough for Project: Timetable Check. A strong project also makes its aim, user, limits, test conditions and failed attempts visible. Use the context of a helper that reads user input and explains invalid entries to produce a short working Python 3 program, sample inputs and expected outputs. Although the lesson aims to “Use dictionaries and lists to build a program that lists lessons and books for a chosen day”, 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 Why does this matter? and Matching days to lessons as the main assumption, then name the test that can confirm or reject it.
2. Acceptance criteria
- Does the code run with Python 3 syntax?
- Do variable and function names explain their purpose?
- Were empty, wrong-type and boundary inputs tested?
- Does an error message tell the user what to correct?
- Can the code be reused without unnecessary repetition?
Do not leave an acceptance criterion for “Project: Timetable 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 “Project: Timetable 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 Why does this matter? or Matching days to lessons should be reconsidered. Remove personal information and private background details from images.
5. Presentation and self-review
Prepare a two-minute explanation of “Project: Timetable Check”: the problem, the solution approach, the most important result for a helper that reads user input and explains invalid entries, 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
The uppercase/lowercase trap
On my first try I forgot to write .lower(). When the user typed Monday, the program said "no timetable found", because the key in the dictionary was the lowercase monday. The expected result and the real result were different; once I found the problem I added .lower() to the input and it was fixed.
Asking for a key that is not in the dictionary
If you write timetable["saturday"] and that key does not exist, Python raises a KeyError and the program stops. That is why it is safer to check with if day in timetable before taking the key directly.
Indentation errors
If you do not indent the lines inside a loop or if by 4 spaces, Python raises an IndentationError. All the lines of a block must line up the same way.
Safety note
This program runs entirely on your own computer and is safe code that you wrote yourself. Only run code that is your own and that you trust. Do not type real personal details like your name, address, or phone number into the program; lesson names and books are enough for this project.
Lesson summary
- A dictionary keeps related data organised by matching each piece of information to a key.
- We stored a day's lessons as a list, and each lesson's book in a separate dictionary.
- With
input().lower().strip()we made the user's input the same no matter how it was typed. - Using
if ... in, aforloop, andnot in, we listed the lessons and found the missing books. - We found and fixed small bugs (uppercase/lowercase,
KeyError, indentation) by testing.
Review questions
- What is a key used for in a dictionary?
- What does the expression
timetable["tuesday"]return? - What do
.lower()and.strip()do to the input? - If we remove the
if day in timetablecheck, what happens when a day that does not exist is entered? - In the missing-book check, what question does
not inask?
Answers
- A key lets us reach the value next to it; it is like finding a word in a dictionary and reading its meaning.
- It returns the lesson list for
tuesday, that is["history", "maths", "music"]. .lower()makes the letters lowercase and.strip()removes the spaces at the start and end, so"Monday"and" monday "are treated the same.- The program raises a
KeyErrorand stops, because we try to take a key that does not exist. - It asks "is this required book not in the list of books in the bag?"; if it is not, that book is missing.
Source and verification note
For “Project: Timetable Check”, verification focuses on whether the relationship between Why does this matter? and Matching days to lessons remains consistent across examples. Code examples follow Python 3 syntax. Small differences may appear between environments, so examples should first be tested in a safe online editor or a local development setup.
Next lesson
Project: Simple Sports Statistics