Home · Academy · Robotics & Coding · Python Fundamentals · Project: Timetable Check

Project: Timetable Check

Use dictionaries and lists to build a program that lists lessons and books for a chosen day.

PROJECT COMPASS

What will you use this page for?

Core idea

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.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

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…

Next connection

Project: Simple Sports Statistics

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration45–75 min
PrerequisiteProject: Number Guessing Game
ContentProject guide · 1,935 words
Last updated

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:

  1. Add the lessons for thursday and friday to the timetable dictionary. For any new lessons, also add a book to the books dictionary.
  2. At the end, print how many books are missing in total. Hint: keep a count = 0 variable and do count = count + 1 for each missing book.
  3. 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

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

3. Test matrix table
TestConditionExpectedActual resultNext decision
NormalStandard input and complete setupThe core task is completedFill in during the testKeep it or make a small improvement
BoundaryLowest or highest accepted valueThe system remains stableFill in during the testReview the threshold or rule
ErrorMissing, wrong or unexpected inputA safe and clear responseFill in during the testAdd error handling
RepeatAt least three trials under the same conditionSimilar resultsFill in during the testInvestigate 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

Review questions

  1. What is a key used for in a dictionary?
  2. What does the expression timetable["tuesday"] return?
  3. What do .lower() and .strip() do to the input?
  4. If we remove the if day in timetable check, what happens when a day that does not exist is entered?
  5. In the missing-book check, what question does not in ask?

Answers

  1. A key lets us reach the value next to it; it is like finding a word in a dictionary and reading its meaning.
  2. It returns the lesson list for tuesday, that is ["history", "maths", "music"].
  3. .lower() makes the letters lowercase and .strip() removes the spaces at the start and end, so "Monday" and " monday " are treated the same.
  4. The program raises a KeyError and stops, because we try to take a key that does not exist.
  5. 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

Start QuizBack to Python Fundamentals
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.