My Weekly Timetable

A school timetable is displayed as a 2D table consisting of 5 rows (for each day of the week) and 5 columns (number of lessons in a day).

Such a table can be stored in a computer program using a 2-dimensional array (2d Array). In python, this is done by creating a list of lists.

Each value of a 2D array can then be accessed by proving two indices: the row number and the column number as displayed on the picture below:
my-timetable-2d-array

Python Challenges


The following 3 tabs contain 3 different challenges, all based on accessing information from the 2D array called timetable.

What Lesson?Today's Lessons?How Many Lessons?
Write a program that:

  1. Asks the user to input a day of the week (e.g. Tuesday)
  2. Asks the user to input a period of the day (between 1 and 5) (e.g. 2)
  3. Retrieves and outputs the lesson on that day and period (e.g. Spanish)
Write a program that:

  1. Asks the user to input a day of the week (e.g. Tuesday)
  2. Displays all five lessons for that day
Write a program that:

  1. Asks the user to input a subject (e.g. Maths)
  2. Counts and outputs the number of lessons for that subject throughout the week. (e.g. “You have 3 Maths lesson this week.”)

Python Code


Use the following code to complete all three challenges mentioned above:

Help?


The following lines of code will help you solve each of the three challenges.
What Lesson?Today's Lessons?How Many Lessons?

Extension Task


Create three different functions for each of the three challenges and add a menu structure to your code to let the user decide what information to retrieve from their timetable.
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.9 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: