1st module
Here I have used a tuple to store the names of all the periods.
Next, I have created a dictionary called TIMINGS, where each
period name is mapped with its corresponding time duration.
Then I have used another dictionary named SUBJECTS to store
the timetable for each day of the week.
Here, each key is a day (Monday to Friday), and the value is a list
which contains subjects for each period on that day.
2nd module
First, I imported the period names, timings, and day-wise subjects
from the data module so that this class can access and use them.
I created a class named S_Teacher, which represents a school
teacher.
Using a class makes the program organized, reusable, and
object-oriented.
This is the constructor method, which runs automatically when
an object is created.
It stores the teacher's name using the variable [Link], so the
teacher's timetable can be displayed with their name.
This function receives a day as input and returns the list of
subjects for that day.
I used the match-case statement, which works like a switch
case.
If the day is valid (Monday to Saturday), the function returns the
subject list from the dictionary.
If the day is invalid, it returns None, which prevents errors.
This function first calls get_day_timetable().
If the day is invalid, it prints "Try Again" and exits .
If the input is valid, it prints a proper heading containing the
teacher's I used a for loop to print the entire timetable in order.
i helps to access each period, corresponding timing, and subject
using index numbers.
The output format becomes:
Period Name → Time → Subject, which makes the timetable neat
and easy to [Link] and selected day.
3rd module
Here, I created an object of the S_Teacher class with the name
“M. Akhtar”.
This object allows the program to access the class functions and
display the timetable
The program uses a while True loop so that the menu keeps
running again and again, allowing the teacher to check any day's
timetable multiple times without restarting the program.
Inside the loop, the program prints a menu showing the list of
days.
The teacher can select a day by entering its corresponding
number.
if the teacher selects number 6, the loop breaks and the program
exits.
The program uses if–elif conditional statements to match the
choice with the correct day.
If the teacher enters a number that is not in the menu, the
program prints an error message instead of crashing.